Class HogHash

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    HogHashAngularEncoded, HogHashDual

    @Experimental("Test")
    public class HogHash
    extends HashingAlgorithm
    Deprecated.
    not ready to use yet
    Image 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 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 image
        height - of the rescaled image
        cellWidth - 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: HashingAlgorithm
        Calculate 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:
        hash in class HashingAlgorithm
        Parameters:
        image - Image whose hash will be calculated
        hash - 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 to
        originalImage - The original image used to create the features. Used as background
        gradientColor - Color of the vectors the vectors
        hog - 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 to
        originalImage - The original image used to create the features. Used as background
        gradientColor - Color of the vectors the vectors
        normalizedHog - hog features to draw
      • precomputeAlgoId

        protected int precomputeAlgoId()
        Deprecated.
        Description copied from class: HashingAlgorithm
        A 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 by HashingAlgorithm.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:
        precomputeAlgoId in class HashingAlgorithm
        Returns:
        the preliminary algorithm id identifying this hashing algorithm