cv

package
v0.0.0-...-03cbb69 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(a int) int

func Color

func Color(img image.Image, x, y int) (int, int, int)

func DecodeXY

func DecodeXY(p int) (int, int)

func DetectLine

func DetectLine(img *BinaryImage)

func EncodeXY

func EncodeXY(x, y int) int

func HSVToRGB

func HSVToRGB(h, s, v float64) (r, g, b uint8)

func HoleNumberInBinaryImage

func HoleNumberInBinaryImage(img *BinaryImage) int

func LineProb

func LineProb(path []int) float64

func Max

func Max(a, b int) int

func Max3

func Max3(a, b, c int) int

func Mean

func Mean(h []float64) float64

func MiddleValue

func MiddleValue(a UInt32Sorter) uint16

func Min

func Min(a, b int) int

func Neighbor8Encoding

func Neighbor8Encoding(img *BinaryImage, x, y int) int

func Neighbor8Sum

func Neighbor8Sum(img *BinaryImage, x, y int) int

func Neighbor8Values

func Neighbor8Values(img *BinaryImage, x, y int) []int

func NeighborColorDiff

func NeighborColorDiff(img image.Image, x, y int) int

func RGBToHSV

func RGBToHSV(r, g, b uint8) (h, s, v float64)

func Var

func Var(h []float64) float64

func VarH

func VarH(h []float64) float64

Types

type AverageSmooth

type AverageSmooth struct {
}

func (*AverageSmooth) Process

func (self *AverageSmooth) Process(img image.Image) image.Image

type BiColorProcessor

type BiColorProcessor interface {
	Process(img image.Image) *BinaryImage
}

type BinaryImage

type BinaryImage struct {
	Width, Height, Size int
	Data                []byte
}

func Convert2BinaryImage

func Convert2BinaryImage(img image.Image) *BinaryImage

func CopyBinaryImage

func CopyBinaryImage(src *BinaryImage) *BinaryImage

func ExtractAllConnectedComponent

func ExtractAllConnectedComponent(img image.Image, dx, dy int) []*BinaryImage

func ExtractAllConnectedComponentInBinaryImage

func ExtractAllConnectedComponentInBinaryImage(img *BinaryImage, dx, dy int) []*BinaryImage

func ExtractLines

func ExtractLines(img *BinaryImage) *BinaryImage
func ExtractLines(img *BinaryImage) *BinaryImage {
	ends := []int{}
	for x := 0; x < img.Width; x++ {
		for y := 0; y < img.Height; y++ {
			p := EncodeXY(x, y)
			if Neighbor8OpenCount(img, p) == 1 {
				ends = append(ends, p)
			}
		}
	}
	for i, p1 := range ends {
		for j, p2 := range ends {
			if j <= i {
				continue
			}
			if HasLine(img, p1, p2) {

			}
		}
	}
}
func AddLine(img *BinaryImage, p1, p2) *BinaryImage{
	for
}
func HasLine(img *BinaryImage, p1, p2 int) bool {
	x1, y1 := p1
	x2, y2 := p2
	if Abs(x1-x2) < 10 && Abs(y1-y2) < 10 {
		return false
	}
	if Abs(x1-x2) > Abs(y1, y2) {
		var xl, xr, yl, yr int
		if x1 < x2 {
			xl, xr = x1, x2
			yl, yr = y1, y2
		} else {
			xl, xr = x2, x1
			yl, yr = y2, y1
		}
		open := 0.0
		total := 0.0
		for x := xl + 1; x < xr; x++ {
			y = yl + (x-xl)*(yr-yl)/(xr-xl)
			if Neighbor8Sum(x, y) > 0 {
				open += 1.0
			}
			total += 1.0
		}
		if open/total > 0.9 {
			return true
		} else {
			return false
		}
	} else {
		var xb, xt, yb, yt int
		if y1 < y2 {
			yb, yt = y1, y2
			xb, xt = x1, x2
		} else {
			yb, yt = y2, y1
			xt, xb = x2, x1
		}
		open := 0.0
		total := 0.0
		for y := yb + 1; y < yt; y++ {
			x = xb + (xt-xb)*(y-yb)/(yt-yb)
			if Neighbor8Sum(x, y) > 0 {
				open += 1.0
			}
			total += 1.0
		}
		if open/total > 0.9 {
			return true
		} else {
			return false
		}
	}
	return false
}

func NewBinaryImage

func NewBinaryImage(width, height int) *BinaryImage

func RemoveLineWithNPixelOpen

func RemoveLineWithNPixelOpen(img *BinaryImage, n int) *BinaryImage

func Rotate

func Rotate(img *BinaryImage, theta float64) *BinaryImage

func (*BinaryImage) Close

func (self *BinaryImage) Close(x, y int)

func (*BinaryImage) Encode

func (self *BinaryImage) Encode() string

func (*BinaryImage) ExtractFeatures

func (self *BinaryImage) ExtractFeatures() []float64

func (*BinaryImage) FeatureEncode

func (self *BinaryImage) FeatureEncode() int

func (*BinaryImage) FrontSize

func (self *BinaryImage) FrontSize() int

func (*BinaryImage) Get

func (self *BinaryImage) Get(x, y int) int

func (*BinaryImage) IsOpen

func (self *BinaryImage) IsOpen(x, y int) bool

func (*BinaryImage) Open

func (self *BinaryImage) Open(x, y int)

func (*BinaryImage) Save

func (self *BinaryImage) Save(name string)

type BinaryImageMeanSmooth

type BinaryImageMeanSmooth struct {
	Threshold int
}

func (*BinaryImageMeanSmooth) Process

func (self *BinaryImageMeanSmooth) Process(img *BinaryImage) *BinaryImage

type BinaryImageProcessor

type BinaryImageProcessor interface {
	Process(img *BinaryImage) *BinaryImage
}

type BoundBinaryImage

type BoundBinaryImage struct {
	XMinOpen, YMinOpen int
}

func (*BoundBinaryImage) Process

func (self *BoundBinaryImage) Process(img *BinaryImage) *BinaryImage

type ColorCount

type ColorCount struct {
	Color int
	Count float64
}

type EntropyBasedBiColor

type EntropyBasedBiColor struct {
}

func (*EntropyBasedBiColor) Process

func (self *EntropyBasedBiColor) Process(img image.Image) *BinaryImage

type Erosion

type Erosion struct {
	Mask []Point
}

func (*Erosion) Process

func (self *Erosion) Process(img *BinaryImage) *BinaryImage

type GrayImage

type GrayImage struct {
	Width, Height, Size int
	Data                []byte
}

func Convert2GrayImage

func Convert2GrayImage(img image.Image) *GrayImage

func CopyGrayImage

func CopyGrayImage(src *GrayImage) *GrayImage

func NewGrayImage

func NewGrayImage(width, height int) *GrayImage

func (*GrayImage) Get

func (self *GrayImage) Get(x, y int) int

func (*GrayImage) Set

func (self *GrayImage) Set(x, y int, val byte)

type ImageProcessor

type ImageProcessor interface {
	Process(img image.Image) image.Image
}

type MaxColorBasedBiColor

type MaxColorBasedBiColor struct {
}

func (*MaxColorBasedBiColor) Process

func (self *MaxColorBasedBiColor) Process(img image.Image) *BinaryImage

type MeanShift

type MeanShift struct {
	K int
}

func (*MeanShift) Process

func (self *MeanShift) Process(img image.Image) image.Image

type PathNode

type PathNode struct {
	// contains filtered or unexported fields
}

func BFSPathExtract

func BFSPathExtract(img *BinaryImage, x0, y0 int) []*PathNode

func CopyPathNode

func CopyPathNode(node *PathNode) *PathNode

func NewPathNode

func NewPathNode() *PathNode

func (*PathNode) AddPoint

func (self *PathNode) AddPoint(x, y int)

func (*PathNode) GetLastPoint

func (self *PathNode) GetLastPoint() (int, int)

type PeakAverageBasedBiColor

type PeakAverageBasedBiColor struct {
}

func (*PeakAverageBasedBiColor) Process

func (self *PeakAverageBasedBiColor) Process(img image.Image) *BinaryImage

type Point

type Point struct {
	X, Y int
}

type RemoveBinaryImageBorder

type RemoveBinaryImageBorder struct {
}

func (*RemoveBinaryImageBorder) Process

func (self *RemoveBinaryImageBorder) Process(img *BinaryImage) *BinaryImage

type RemoveIsolatePoints

type RemoveIsolatePoints struct {
}

func (*RemoveIsolatePoints) Process

func (self *RemoveIsolatePoints) Process(img *BinaryImage) *BinaryImage

type RemoveXAxis

type RemoveXAxis struct {
	K int
}

func (*RemoveXAxis) Process

func (self *RemoveXAxis) Process(img *BinaryImage) *BinaryImage

type ScaleBinaryImage

type ScaleBinaryImage struct {
	Height int
}

func (*ScaleBinaryImage) Process

func (self *ScaleBinaryImage) Process(img *BinaryImage) *BinaryImage

type Thining

type Thining struct {
}

func (*Thining) Process

func (self *Thining) Process(img *BinaryImage) *BinaryImage

type UInt32Sorter

type UInt32Sorter []uint32

func (UInt32Sorter) Len

func (ms UInt32Sorter) Len() int

func (UInt32Sorter) Less

func (ms UInt32Sorter) Less(i, j int) bool

func (UInt32Sorter) Swap

func (ms UInt32Sorter) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL