Class HogHash
- java.lang.Object
-
- dev.brachtendorf.jimagehash.hashAlgorithms.HashingAlgorithm
-
- dev.brachtendorf.jimagehash.hashAlgorithms.experimental.HogHash
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
HogHashAngularEncoded,HogHashDual
@Experimental("Test") public class HogHash extends HashingAlgorithm
Deprecated.not ready to use yetImage Hash on HOG feature descriptor. Not ready yet. Most likely use a very high bit resolution similar to how hog feature descriptors are actually used Requires at least 64 bit to produce reasonable results- Since:
- 2.0.0
- Author:
- Kilian
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcellWidthDeprecated.The cell width/height used to compute the featuresprotected intheightDeprecated.The height of the rescaled imageprotected intnumBinsDeprecated.The number of angle bins per cellprotected static longserialVersionUIDDeprecated.protected intwidthDeprecated.The width of the rescaled imageprotected intxCellsDeprecated.The number of cells in x dimensionprotected intyCellsDeprecated.The number of cells in y dimension-
Fields inherited from class dev.brachtendorf.jimagehash.hashAlgorithms.HashingAlgorithm
bitResolution, immutableState, keyResolution, opaqueReplacementColor, opaqueReplacementThreshold, preProcessing
-
-
Constructor Summary
Constructors Constructor Description HogHash(int bitResolution)Deprecated.Create a hog hasher with the target bit resolution.HogHash(int width, int height, int cellWidth, int numBins)Deprecated.Create a hog hasher with parameters specific to the hog feature detection algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected double[][][]blockNormalization(int[][][] hog)Deprecated.protected int[][][]computeHogFeatures(int[][] lum)Deprecated.protected BigIntegerhash(BufferedImage image, HashBuilder hash)Deprecated.Calculate a hash for the given image.protected intprecomputeAlgoId()Deprecated.A unique id identifying the settings and algorithms used to generate the output result.protected voidtoImage(File outputFile, BufferedImage originalImage, Color gradientColor, double[][][] normalizedHog)Deprecated.Create a visual representation of the normalized hog features.protected voidtoImage(File outputFile, BufferedImage originalImage, Color gradientColor, int[][][] hog)Deprecated.Create a visual representation of the hog features.StringtoString()Deprecated.-
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
-
-
-
-
Field Detail
-
serialVersionUID
protected static final long serialVersionUID
Deprecated.- See Also:
- Constant Field Values
-
width
protected int width
Deprecated.The width of the rescaled image
-
height
protected int height
Deprecated.The height of the rescaled image
-
cellWidth
protected int cellWidth
Deprecated.The cell width/height used to compute the features
-
xCells
protected int xCells
Deprecated.The number of cells in x dimension
-
yCells
protected int yCells
Deprecated.The number of cells in y dimension
-
numBins
protected int numBins
Deprecated.The number of angle bins per cell
-
-
Constructor Detail
-
HogHash
public HogHash(int width, int height, int cellWidth, int numBins)Deprecated.Create a hog hasher with parameters specific to the hog feature detection algorithm. The actual hash will have a key length of(width / cellWidth) * (height / cellWidth) * numBins- Parameters:
width- of the rescaled imageheight- of the rescaled imagecellWidth- the width and height of sub cell. For each cell a gradient will be computed. The cell width has to be a divisor of width AND height!numBins- the number of bins per cell. The number of bins represent the angular granularity the gradients will be sorted into. The gradients will be sorted into buckets equivalent of the size of 180°/numBins- Throws:
IllegalArgumentException- if width or height can't be divided by cellWidth or if any of the arguments is smaller or equal 0
-
HogHash
public HogHash(int bitResolution)
Deprecated.Create a hog hasher with the target bit resolution. Default values of 4 bins per cell (0°,45°,90°,135°) and a cell width of 2 pixels per cell are assumed.- Parameters:
bitResolution- the bit resolution of the final hash. The hash will be at least the specified bits but may be bigger due to algorithmic constraints. The best attempt is made to return a hash with the given number of bits.
-
-
Method Detail
-
hash
protected BigInteger hash(BufferedImage image, HashBuilder hash)
Deprecated.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.- Specified by:
hashin classHashingAlgorithm- Parameters:
image- Image whose hash will be calculatedhash- a hash builder used to construct the hash- Returns:
- the hash encoded as a big integer
-
computeHogFeatures
protected int[][][] computeHogFeatures(int[][] lum)
Deprecated.
-
blockNormalization
protected double[][][] blockNormalization(int[][][] hog)
Deprecated.
-
toImage
protected void toImage(File outputFile, BufferedImage originalImage, Color gradientColor, int[][][] hog)
Deprecated.Create a visual representation of the hog features. Debug method- Parameters:
outputFile- The file to save the image tooriginalImage- The original image used to create the features. Used as backgroundgradientColor- Color of the vectors the vectorshog- hog features to draw
-
toImage
protected void toImage(File outputFile, BufferedImage originalImage, Color gradientColor, double[][][] normalizedHog)
Deprecated.Create a visual representation of the normalized hog features. Debug method- Parameters:
outputFile- The file to save the image tooriginalImage- The original image used to create the features. Used as backgroundgradientColor- Color of the vectors the vectorsnormalizedHog- hog features to draw
-
toString
public String toString()
Deprecated.- Overrides:
toStringin classHashingAlgorithm
-
precomputeAlgoId
protected int precomputeAlgoId()
Deprecated.Description copied from class:HashingAlgorithmA unique id identifying the settings and algorithms used to generate the output result. This method shall contain a hash code for the object which- Stays consistent throughout restart of the jvm
- Value does not change after the constructor finished
- Must return the same value if two instances compute the same hashes for identical input
Even if different bitResolutions are used in the constructor
HashingAlgorithm(int)the algorithId MUST return the same id for two instances if the returned hashes for the same input will always be equal. Therefore instead of checking against the bitResolution the actual resolution as returned byHashingAlgorithm.getKeyResolution()should be used. This method algorithm id's as information available to the child class and will be extended by the hashcode of the kernels.- Specified by:
precomputeAlgoIdin classHashingAlgorithm- Returns:
- the preliminary algorithm id identifying this hashing algorithm
-
-