Class AbstractCategoricalMatcher

  • All Implemented Interfaces:
    CategoricalImageMatcher
    Direct Known Subclasses:
    CategoricalMatcher

    public abstract class AbstractCategoricalMatcher
    extends PlainImageMatcher
    implements CategoricalImageMatcher
    An abstract implementation of the categorical image matcher supporting classes to keep track of the categories an image was matched to.

    It is up to the implementing class to keep the field cachedImagesInCategory and reverseImageCategoryMap in a valid state.

    Since:
    3.0.0
    Author:
    Kilian
    • Constructor Detail

      • AbstractCategoricalMatcher

        public AbstractCategoricalMatcher()
    • Method Detail

      • categorizeImageAndAdd

        public abstract CategorizationResult categorizeImageAndAdd​(BufferedImage bi,
                                                                   String uniqueId)
        Description copied from interface: CategoricalImageMatcher
        Compute the closest category of an image and afterwards add it to the internal categorization queue. Some matchers may choose to immediately update the current category to reflect the changes.

        The add action is implementation depended. Some categorizers may choose to directly incorporate the image and update it's category representation other algorithms may require a call to CategoricalImageMatcher.recomputeCategories() before the addition takes effect.

        Specified by:
        categorizeImageAndAdd in interface CategoricalImageMatcher
        Parameters:
        bi - the image to categorize
        uniqueId - the unique id to reference the image by.
        Returns:
        the currently closest cluster for this image.
      • getCategory

        public int getCategory​(String uniqueId)
        Description copied from interface: CategoricalImageMatcher
        Get the current category of the image described by this unique id. A category usually maps an image to a cluster.
        Specified by:
        getCategory in interface CategoricalImageMatcher
        Parameters:
        uniqueId - the id of a previously added image
        Returns:
        the category
      • categorizeImage

        public CategorizationResult categorizeImage​(BufferedImage bi)
        Description copied from interface: CategoricalImageMatcher
        Compute the category of the supplied image. A category is a collection of similar images mapped to a common hash which minimizes the distance of all hashes mapped to this category.
        Specified by:
        categorizeImage in interface CategoricalImageMatcher
        Parameters:
        bi - The buffered image to categorize
        Returns:
        a pair whose first value returns the category and second value returns a distance measure between the category and the supplied image. Smaller distances meaning a closer match
      • isCategorized

        public boolean isCategorized​(String uniqueId)
        Check if an image has already been added to the categorizer
        Parameters:
        uniqueId - the unique id of the image
        Returns:
        true if it has been added, false otherwise
      • getImageCountInCategory

        public int getImageCountInCategory​(int category)
        Get the number of images that are were added in this category.
        Parameters:
        category - to retrieve the number of images from.
        Returns:
        he number of images that were mapped and added to this category