Class WeightedCategoricalMatcher

  • All Implemented Interfaces:
    CategoricalImageMatcher

    public class WeightedCategoricalMatcher
    extends CategoricalMatcher
    Cluster images into common categories. This matcher clusters images by computing the distance to the closest cluster and adds an image if it is within a given distance. This method works only approximate CategoricalMatcher.recomputeCategories() has to be called after images have been added.

    Cluster centeroids are represented as FuzzyHashes a prot hash represented as mode hash of all added images.

    Opposed to the categorical matcher this matcher calculates the distances to clusters using the weighted distance, resulting in more accurate results but at the cost of increase computational requirements.

    Since:
    3.0.0
    Author:
    Kilian
    • Method Detail

      • computeDistanceForCategory

        protected double computeDistanceForCategory​(Hash[] hashes,
                                                    int category,
                                                    double bestDistance)
        Description copied from class: CategoricalMatcher
        Compute the distance between an image and a category cluster midpoint. This method is used to compute the minimum distance and therefore might cut the computation short if the distance is higher than the supplied best distance cutoff.
        Overrides:
        computeDistanceForCategory in class CategoricalMatcher
        Parameters:
        hashes - an array containing the hash for an image for each hashing algorithm added to this matcher
        category - the category to compute the distance for
        bestDistance - the best distance found so far. May be used to
        Returns:
        the distance between the image and the category midpoint or Double.MAX_VALUE if bestDistance was reached and copmutation was not finished
      • addHashingAlgorithm

        public boolean addHashingAlgorithm​(HashingAlgorithm algo)
        Description copied from class: PlainImageMatcher
        Append a new hashing algorithm to be used by this matcher. The same algorithm may only be added once. Attempts to add the same algorithm twice is a NOP.

        For some matchers the order of added hashing algorithms is crucial. The order the hashes are added is preserved.

        Overrides:
        addHashingAlgorithm in class CategoricalMatcher
        Parameters:
        algo - The algorithms to be added
        Returns:
        true if the algorithm was added, false if it was already present