public class ClassifierKNearestNeighborsBow<T extends boofcv.struct.image.ImageBase<T>,Desc extends boofcv.struct.feature.TupleDesc>
extends java.lang.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 and Description |
|---|
ClassifierKNearestNeighborsBow(org.ddogleg.nn.NearestNeighbor<HistogramScene> nn,
boofcv.abst.feature.dense.DescribeImageDense<T,Desc> describe,
FeatureToWordHistogram<Desc> featureToHistogram)
Configures internal algorithms.
|
| Modifier and Type | Method and Description |
|---|---|
int |
classify(T image)
Finds the scene which most resembles the provided image
|
void |
setClassificationData(java.util.List<HistogramScene> memory,
int numScenes)
Provides a set of labeled word histograms to use to classify a new image
|
void |
setNumNeighbors(int numNeighbors)
Specifies the number of neighbors it should search for when classifying\
|
public ClassifierKNearestNeighborsBow(org.ddogleg.nn.NearestNeighbor<HistogramScene> nn, boofcv.abst.feature.dense.DescribeImageDense<T,Desc> describe, FeatureToWordHistogram<Desc> featureToHistogram)
nn - Used to perform nearest-neighbor searchdescribe - Computes the dense image featuresfeatureToHistogram - Converts a set of features into a word histogrampublic void setNumNeighbors(int numNeighbors)
public void setClassificationData(java.util.List<HistogramScene> memory, int numScenes)
memory - labeled histogramspublic int classify(T image)
image - Image that's to be classified