Documentation ¶
Index ¶
- func Ahash(img image.Image, hashLen int) ([]byte, error)
- func Dhash(img image.Image, hashLen int) ([]byte, error)
- func DhashHorizontal(img image.Image, hashLen int) ([]byte, error)
- func DhashVertical(img image.Image, hashLen int) ([]byte, error)
- func GetDistance(hash1, hash2 []byte) int
- func GetDistanceMaxRange(hash1, hash2 []byte) int
- func OpenImg(fp string) (image.Image, error)
- type BitArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ahash ¶
Ahash calculates the average hash of an image. The image is first grayscaled, then scaled down to "hashLen" for the width and height. Then, the average value of the pixels is computed, and if a pixel is above the average, a 1 is appended to the byte array; a 0 otherwise.
func Dhash ¶
Dhash calculates the horizontal and vertical gradient hashes separately, then concatenates then to return one result as: <horizontal><vertical>. 'img' is an Image object returned by opening an image file using OpenImg(). 'hashLen' is the size that the image will be shrunk to. It must be a non-zero multiple of 8.
func DhashHorizontal ¶
DhashHorizontal returns the result of a horizontal gradient hash. 'img' is an Image object returned by opening an image file using OpenImg(). 'hashLen' is the size that the image will be shrunk to. It must be a non-zero multiple of 8.
func DhashVertical ¶
DhashVertical returns the result of a vertical gradient hash. 'img' is an Image object returned by opening an image file using OpenImg(). 'hashLen' is the size that the image will be shrunk to. It must be a non-zero multiple of 8.
func GetDistance ¶
GetDistance returns the hamming distance between two hashs
func GetDistanceMaxRange ¶
GetDistanceMaxRange returns the distance between two hashs
Types ¶
type BitArray ¶
type BitArray struct {
// contains filtered or unexported fields
}
BitArray is an internal struct used by dhash to simplify appending bits to a byte array from left to right.
func NewBitArray ¶
NewBitArray is a constructor function for the BitArray struct. The input, 'numBits' is the number of bits this byte array will hold, so it must be a non-zero multiple of 8.