Class AverageColorHash
- java.lang.Object
-
- dev.brachtendorf.jimagehash.hashAlgorithms.HashingAlgorithm
-
- dev.brachtendorf.jimagehash.hashAlgorithms.AverageHash
-
- dev.brachtendorf.jimagehash.hashAlgorithms.AverageColorHash
-
- All Implemented Interfaces:
Serializable
public class AverageColorHash extends AverageHash
Calculate a hash value based on the average rgb color in an image.- Since:
- 2.0.0 similar to ahash from version 1.0.0
- Author:
- Kilian
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.AverageHash
height, width
-
Fields inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.HashingAlgorithm
bitResolution, immutableState, keyResolution, opaqueReplacementColor, opaqueReplacementThreshold, preProcessing
-
-
Constructor Summary
Constructors Constructor Description AverageColorHash(int bitResolution)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected BigIntegerhash(BufferedImage image, HashBuilder hash)Calculate a hash for the given image.-
Methods inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.AverageHash
computeHash, computeHash, precomputeAlgoId
-
Methods inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.HashingAlgorithm
addFilter, algorithmId, createAlgorithmSpecificHash, createPixelAccessor, equals, getKeyResolution, getOpaqueReplacementColor, getOpaqueReplacementThreshold, hash, hash, hash, hash, hashCode, removeFilter, setOpaqueHandling, setOpaqueHandling, toString
-
-
-
-
Constructor Detail
-
AverageColorHash
public AverageColorHash(int bitResolution)
- Parameters:
bitResolution- The bit resolution specifies the final length of the generated hash. A higher resolution will increase computation time and space requirement while being able to track finer detail in the image. Be aware that a high key is not always desired.The average hash requires to re scale the base image according to the required bit resolution. If the square root of the bit resolution is not a natural number the resolution will be rounded to the next whole number.
The average hash will produce a hash with at least the number of bits defined by this argument. In turn this also means that different bit resolutions may be mapped to the same final key length.64 = 8x8 = 65 bit key 128 = 11.3 -> 12 -> 144 bit key 256 = 16 x 16 = 256 bit key
-
-
Method Detail
-
hash
protected BigInteger hash(BufferedImage image, HashBuilder hash)
Description copied from class:HashingAlgorithmCalculate a hash for the given image. Invoking the hash function on the same image has to return the same hash value. A comparison of the hashes relates to the similarity of the images. The lower the value the more similar the images are. Equal images will produce a similarity of 0.This method is intended to be overwritten by implementations and takes a baseHash argument to allow concatenating multiple hashes as well to be able to compute the effective hash length in
HashingAlgorithm.getKeyResolution(). Preceding 0's are omitted in big integer objects, while the usual hamming distance can be calculated due to xoring without issue the normalized distance requires the potential length of the key to be known.- Overrides:
hashin classAverageHash- Parameters:
image- Image whose hash will be calculatedhash- a hash builder used to construct the hash- Returns:
- the hash encoded as a big integer
-
-