leonard

package
v0.0.0-...-fc13e92 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBinaryThreshold = 0x28F6 // 0.16 * 0xFFFF

DefaultBinaryThreshold is the default threshold used for binary images.

Variables

This section is empty.

Functions

func Binary

func Binary(img image.Image) image.Image

Binary returns a binary image. Use NewBinaryImage to use a custom threshold.

func Downscale

func Downscale(img image.Image) image.Image

Downscale reduces the size of an image by 4x (width/2 and height/2) by averaging the values of 4-pixels squares.

func GaussianFilter

func GaussianFilter(img image.Image, sigma float64) image.Image

GaussianFilter applies a gaussian filter with the given sigma parameter on the image.

func Gradients

func Gradients(img image.Image) image.Image

Gradients returns an image that represents the magnitude of gradients

func Grayscale

func Grayscale(img image.Image) image.Image

Grayscale converts a colored image to a grayscaled one

func HorizontalGradients

func HorizontalGradients(img image.Image) image.Image

HorizontalGradients returns an image that represents the magnitude of the horizontal gradients

func LoadImage

func LoadImage(filename string) (image.Image, error)

LoadImage loads an image from a file. If the filename is "-" the image is read from os.Stdin.

func SaveImage

func SaveImage(img image.Image, filename string) error

SaveImage saves an image to a file. The correct format is guessed from the file extension. The default format for files without extension is PNG.

func VerticalGradients

func VerticalGradients(img image.Image) image.Image

VerticalGradients returns an image that represents the magnitude of the vertical gradients

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.

Jump to

Keyboard shortcuts

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