Hasher
TheHasher interface defines the contract for computing perceptual hashes from images. All hash algorithms in imghash implement this interface.
Methods
Computes a perceptual hash from the provided image.
The input image to hash. Accepts any type that implements the standard
image.Image interface.The computed hash. The concrete type depends on the algorithm:
- Binary hash algorithms (Average, Difference, Median, PHash, etc.) return
hashtype.Binary - Histogram-based algorithms (CLD, EHD, etc.) return
hashtype.UInt8 - Feature-based algorithms (ColorMoment, GIST, etc.) return
hashtype.Float64
Returns an error if the hash computation fails. Possible errors include invalid image dimensions or algorithm-specific failures.
Implementing Algorithms
All hash algorithms in imghash implement theHasher interface:
- Average - Average hash algorithm
- Difference - Difference hash algorithm
- Median - Median hash algorithm
- PHash - Perceptual hash using DCT
- BlockMean - Block mean hash
- MarrHildreth - Marr-Hildreth edge detection hash
- RadialVariance - Radial variance hash
- ColorMoment - Color moment hash
- CLD - Color Layout Descriptor
- EHD - Edge Histogram Descriptor
- WHash - Wavelet hash
- LBP - Local Binary Pattern hash
- HOGHash - Histogram of Oriented Gradients hash
- BoVW - Bag of Visual Words hash
- PDQ - Facebook’s PDQ hash
- RASH - Robust Affine-invariant Spatial Hash
- Zernike - Zernike moments hash
- GIST - GIST descriptor hash
Usage Example
Using Different Algorithms
Polymorphic Usage
See Also
- Comparer Interface - For comparing hashes
- Hash Types - Hash type definitions
- Convenience Functions - Helper functions for common tasks