hash

package
v0.0.0-...-c5885c7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ahash

func Ahash(img image.Image, hashLen int) ([]byte, error)

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

func Dhash(img image.Image, hashLen int) ([]byte, error)

func DhashHorizontal

func DhashHorizontal(img image.Image, hashLen int) ([]byte, error)

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

func DhashVertical(img image.Image, hashLen int) ([]byte, error)

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.

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

func NewBitArray(numBits int) (*BitArray, error)

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.

func (*BitArray) AppendBit

func (ab *BitArray) AppendBit(bit int) error

AppendBit appends a 1 or a 0 to the byte array in the BitArray struct. Valid input is an int of '1' or '0', and this function cannot be called after the byte array has filled up.

func (BitArray) GetArray

func (ab BitArray) GetArray() []byte

GetArray returns the byte array in its current state. It can be called at any time.

Jump to

Keyboard shortcuts

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