Documentation ¶
Overview ¶
Package images allows image comparison by perceptual similarity. Supported image types are those default to the Go image package https://golang.org/pkg/image/ (which are GIF, JPEG and PNG in October 2018).
Index ¶
- func Gif(img *image.RGBA, path string)
- func Hash(img image.Image) (h []float32, imgSize image.Point)
- func Jpg(img *image.RGBA, path string, quality int)
- func Open(path string) (img image.Image, err error)
- func Png(img *image.RGBA, path string)
- func ResampleByNearest(inImg image.Image, outImgSize image.Point) (outImg image.RGBA, inImgSize image.Point)
- func Similar(hA, hB []float32, imgSizeA, imgSizeB image.Point) bool
- func SimilarCustom(hA, hB []float32, imgSizeA, imgSizeB image.Point) (delta, euc, eucNorm, corr float32)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Hash ¶
Hash calculates a slice of average color values of an image at the position of white pixels of a mask. One average value corresponds to one mask. The function also returns the original image width and height.
func ResampleByNearest ¶
func ResampleByNearest(inImg image.Image, outImgSize image.Point) ( outImg image.RGBA, inImgSize image.Point)
ResampleByNearest resizes an image by the nearest neighbour method to the output size outX, outY. It also returns the size inX, inY of the input image.
func Similar ¶
Similar function gives a verdict for image A and B based on their hashes and sizes. The input parameters are generated with the Hash function.
func SimilarCustom ¶ added in v2.1.0
func SimilarCustom(hA, hB []float32, imgSizeA, imgSizeB image.Point) ( delta, euc, eucNorm, corr float32)
SimilarCustom function returns similarity metrics instead of returning a verdict as the function Similar does. Then you can decide on your own which thresholds to use for each filter, or filter/rank by combining the values. delta is image proportions metric (sizeThreshold in func Similar). The larger the delta the more distinct are images by their proportions. euc is Euclidean metric. The larger euc is the more distinct are images visually. eucNorm is Euclidean metric for normalized hash values (visially similar to autolevels in graphic editors). The larger eucNorm is the more distinct are images visually after autolevelling (normalization). corr is sign correlation of color values. The larger the value the more similar are images (correlate more to each other). Demo returned values are used in TestSimilarCustom function.
Types ¶
This section is empty.