Class ClassifierKNearestNeighborsBow<T extends ImageBase<T>,​TD extends TupleDesc<TD>>


public class ClassifierKNearestNeighborsBow<T extends ImageBase<T>,​TD extends TupleDesc<TD>>
extends Object

Scene classification which uses bag-of-word model and K-Nearest Neighbors. Classification data consists of a labeled set of word histograms. Each word histogram was created by 1) extracting all the features inside an image which was known to belong to a specific scene, 2) the word which best matches each feature is found and added to the histogram, and 3) the histogram is then normalized so that it adds up to one.

When classifying an image its word histogram is computed the same way. Using the just computed histogram the K-nearest neighbors to its word histogram are found in the classification data. The most frequent scene (the mode) of the k-neighbors is the selected scene type of the image being considered.

  • Constructor Details

    • ClassifierKNearestNeighborsBow

      public ClassifierKNearestNeighborsBow​(NearestNeighbor<HistogramScene> nn, DescribeImageDense<T,​TD> describe, FeatureToWordHistogram<TD> featureToHistogram)
      Configures internal algorithms.
      nn - Used to perform nearest-neighbor search
      describe - Computes the dense image features
      featureToHistogram - Converts a set of features into a word histogram
  • Method Details

    • setNumNeighbors

      public void setNumNeighbors​(int numNeighbors)
      Specifies the number of neighbors it should search for when classifying\
    • setClassificationData

      public void setClassificationData​(List<HistogramScene> memory, int numScenes)
      Provides a set of labeled word histograms to use to classify a new image
      memory - labeled histograms
    • classify

      public int classify​(T image)
      Finds the scene which most resembles the provided image
      image - Image that's to be classified
      The index of the scene it most resembles