vision

package module
v0.0.0-...-c25cc30 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: MIT Imports: 13 Imported by: 0

README

vision

Computer Vision algorithms in Go

Documentation

Overview

Package vision provides common algorithms used in computer vision

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blobs

func Blobs(input *image.Image, connectivity Connectivity) *image.RGBA

Blobs paint all connected white blobs in a different RGB color

func Canny

func Canny(img image.Image, upperThreshold, lowerThreshold uint8, k int, σ float64) (j *image.Gray)

Canny implements the popular canny edge detector

func Detect

func Detect(I image.Image) (R image.Rectangle)

func EdgeDrawing

func EdgeDrawing(gray *image.Gray) *image.Gray

func Gaussian

func Gaussian(gray *image.Gray, sigma float64) *image.Gray

func GenerateKey

func GenerateKey(theta, rho int) int

GenerateKey returns an unique integer representation for each Hough point.

func Grad

func Grad(gray *image.Gray) (mag, ang *image.Gray)

Grad computes the grad and returns its magnitude and angle.

func Gray2Mat

func Gray2Mat(i *image.Gray) *matrix.Matrix

Gray2Mat converts a gray scale image to matrix.

func Harris

func Harris(img *image.Gray, measure, k, d, i float32, strategy string, cells, N int, subpixel bool) (x, y *[]int)

Harris implements the Harris corner detector as described in Javier Sánchez, Nelson Monzón, and Agustín Salgado, An Analysis and Implementation of the Harris Corner Detector, Image Processing On Line, 8 (2018), pp. 305–328. https://doi.org/10.5201/ipol.2018.229

func Im2Mat

func Im2Mat(i image.Image) (array []*matrix.Matrix)

Im2Mat converts an image to an array of matrices. The output array contains a single matrix if the input is a grayscale image or four matrices if it is a RGBA image. When converting from RGBA, the channel to index correspondence is the following:

RED 	-> 0
GREEN 	-> 1
BLUE 	-> 2
ALPHA 	-> 3

If the image pointer is nil the function produces nothing and returns a nil pointer, so remember always checking for nil when using it.

func ListBlobs

func ListBlobs(i *image.Image, connectivity Connectivity) *[]Blob

ListBlobs returns a list of all white connected blobs

func Mat2Gray

func Mat2Gray(mat *matrix.Matrix) (gray *image.Gray)

Mat2Gray converts a matrix into a gray scale image.

func Mat2Im

func Mat2Im(array []*matrix.Matrix) (ptr *image.Image)

Mat2Im converts an valid array of matrices to an 8-bit color depth image and returns a pointer to it. A valid array contains matrices of same size. The function produces a grayscale image if the array has a single matrix and a RGBA image if it has four matrices. When converting to RGBA, the index to channel correspondence is the following:

0 -> RED
1 -> GREEN
2 -> BLUE
3 -> ALPHA

If the array is not valid the function produces nothing and returns a nil pointer, so remember always checking for nil when using it.

func Stack

func Stack(I image.RGBA, R image.Rectangle) (O []image.Image)

func Threshold

func Threshold(img *image.Image, level uint8) (out *image.Gray)

Types

type Blob

type Blob struct {
	Bounds   image.Rectangle
	Centroid image.Point
	Area     int
	Points   []image.Point
}

Blob represents a blob

func (*Blob) ClosestPoint

func (b *Blob) ClosestPoint(a image.Point) image.Point

type Connectivity

type Connectivity int

Connectivity is an image graph connectivity for use in blob detection

const (
	// Connectivity8 8-connected image graph
	Connectivity8 Connectivity = iota

	// Connectivity4 4-connected image graph
	Connectivity4
)

type HoughPoint

type HoughPoint struct {
	Indexes    []int
	Score      int
	SpatialMin []int
	SpatialMax []int
}

HoughPoint represents a single point in the Hough space with its score, theta and rho values and and minimum and maximum corresponding spatial points.

func (HoughPoint) String

func (h HoughPoint) String() string

String returns a string representation of the HoughPoint.

type HoughSpace

type HoughSpace struct {
	ThetaRes      int
	RhoRes        int
	MaxScore      int
	MinScore      int
	SpatialBounds image.Rectangle
	// contains filtered or unexported fields
}

HoughSpace stores the relevant data from the Hough transform algorithm.

func NewHoughSpace

func NewHoughSpace(input *image.Gray, thetaRes, rhoRes int) *HoughSpace

NewHoughSpace performs the Hough transform in the input space image and returns a HoughSpace struct pointer with the given theta and rho resolutions.

func (*HoughSpace) At

func (h *HoughSpace) At(theta, rho int) (*HoughPoint, bool)

At returns the Hough point at theta and rho indexes.

func (*HoughSpace) Count

func (h *HoughSpace) Count() int

Count returns the total number of Hough points.

func (*HoughSpace) FindCentroids

func (h *HoughSpace) FindCentroids(threshold uint8) *HoughSpace

FindCentroids thresholds the image of the Hough space, find its blobs and return a new Hough space containing only the most representative point for each blob.

func (*HoughSpace) HoughImage

func (h *HoughSpace) HoughImage() *image.Gray

HoughImage rescales the scores in the Hough space to the interval [0, 255] and plot it in a grayscale image.

func (*HoughSpace) PlotLines

func (h *HoughSpace) PlotLines() *image.Gray

PlotLines returns an image with line segments for each corresponding point in the Hough space.

func (*HoughSpace) Set

func (h *HoughSpace) Set(theta, rho int, hp *HoughPoint)

Set overwrites the Hough point at theta and rho indexes.

type Region

type Region struct {
	D      []float64
	Xi, Xf []int
	Yi, Yf []int
}

func Find

func Find(O, I *matrix.Matrix, dist float64) (R *Region)

Find finds O in I

func (*Region) Len

func (R *Region) Len() int

func (*Region) Less

func (R *Region) Less(i, j int) bool

func (*Region) Swap

func (R *Region) Swap(i, j int)

Directories

Path Synopsis
Package kernel provides helper functions for generating convolution kernels.
Package kernel provides helper functions for generating convolution kernels.

Jump to

Keyboard shortcuts

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