Documentation ¶
Index ¶
- Constants
- func Binary(img image.Image) image.Image
- func Downscale(img image.Image) image.Image
- func GaussianFilter(img image.Image, sigma float64) image.Image
- func Gradients(img image.Image) image.Image
- func Grayscale(img image.Image) image.Image
- func HorizontalGradients(img image.Image) image.Image
- func LoadImage(filename string) (image.Image, error)
- func SaveImage(img image.Image, filename string) error
- func VerticalGradients(img image.Image) image.Image
- type BinaryImage
- func (b *BinaryImage) At(x, y int) color.Color
- func (b *BinaryImage) Bounds() image.Rectangle
- func (b *BinaryImage) Clone() *BinaryImage
- func (b *BinaryImage) ColorModel() color.Model
- func (b *BinaryImage) DrawLines(acc *houghAccumulator)
- func (b *BinaryImage) EachPixel(fn func(x, y int))
- func (b *BinaryImage) Get(x, y int) bool
- func (b *BinaryImage) HoughTransform() *houghAccumulator
- func (b *BinaryImage) Invert()
- func (b *BinaryImage) Set(x, y int, value bool)
- func (b *BinaryImage) ThinEdges() *BinaryImage
Constants ¶
const DefaultBinaryThreshold = 0x28F6 // 0.16 * 0xFFFF
DefaultBinaryThreshold is the default threshold used for binary images.
Variables ¶
This section is empty.
Functions ¶
func Downscale ¶
Downscale reduces the size of an image by 4x (width/2 and height/2) by averaging the values of 4-pixels squares.
func GaussianFilter ¶
GaussianFilter applies a gaussian filter with the given sigma parameter on the image.
func HorizontalGradients ¶
HorizontalGradients returns an image that represents the magnitude of the horizontal gradients
func LoadImage ¶
LoadImage loads an image from a file. If the filename is "-" the image is read from os.Stdin.
Types ¶
type BinaryImage ¶
type BinaryImage struct {
// contains filtered or unexported fields
}
BinaryImage is a black & white image represented as a boolean matrix.
White represents true pixels and black represents false ones. The underlying representation is optimized for sparse matrices; i.e. with a lot more false values than true ones.
func NewBinaryImage ¶
func NewBinaryImage(img image.Image, threshold int) *BinaryImage
NewBinaryImage creates a new binary image from a given one. The default threshold is used is the passed value is -1.
func NewEmptyBinaryImage ¶
func NewEmptyBinaryImage(height, width int) *BinaryImage
NewEmptyBinaryImage returns a new empty (= all black) binary image
func (*BinaryImage) At ¶
func (b *BinaryImage) At(x, y int) color.Color
At implements the image.Image interface
func (*BinaryImage) Bounds ¶
func (b *BinaryImage) Bounds() image.Rectangle
Bounds implements the image.Image interface
func (*BinaryImage) Clone ¶
func (b *BinaryImage) Clone() *BinaryImage
func (*BinaryImage) ColorModel ¶
func (b *BinaryImage) ColorModel() color.Model
ColorModel implements the image.Image interface
func (*BinaryImage) DrawLines ¶
func (b *BinaryImage) DrawLines(acc *houghAccumulator)
DrawLines takes an (r, theta) accumulator as returned by HoughTransform and draw the corresponding lines on the image.
func (*BinaryImage) EachPixel ¶
func (b *BinaryImage) EachPixel(fn func(x, y int))
EachPixel calls the given function on each truthy pixel
func (*BinaryImage) Get ¶
func (b *BinaryImage) Get(x, y int) bool
Get returns the boolean value at a given pixel
func (*BinaryImage) HoughTransform ¶
func (b *BinaryImage) HoughTransform() *houghAccumulator
HoughTransform performs a Hough Transform on the image and return an (r, theta) accumulator.
func (*BinaryImage) Invert ¶
func (b *BinaryImage) Invert()
Invert inverts the image.
Black pixels become white and white ones become black.
func (*BinaryImage) Set ¶
func (b *BinaryImage) Set(x, y int, value bool)
Set sets the value at a given pixel
func (*BinaryImage) ThinEdges ¶
func (b *BinaryImage) ThinEdges() *BinaryImage
ThinEdges thins the edges of an image [that went through Gradients()] and return it. The image is modified in-place.