OpenCV


18
Jul 11

Using the Normal Bayes classifier for image categorization in OpenCV

This article is a follow up to “The Bag of Words model in OpenCV 2.2” in which I explained how to use the BoW classes in OpenCV to create BoW representations for images. Here I will explain how to use the Normal Bayes Classifier -which is also implemented in OpenCV- to categorize images.

In this article we treat image categorization as a supervised learning task. For those who don’t know what supervised learning is I will not try to give an introduction here. Please have a look at wikipedia.

The Normal Bayes Classifier is a very simple classifier which assumes that the class-conditional distribution of the data is normal. Consequently, what the classifier does, is estimate the covariance matrices and means per class. To classify an instance, it chooses the class under whose class-conditional density the instance has the highest probability. Continue reading →


8
Jul 11

The Bag of Words model in OpenCV 2.2

In this article I will give an introduction to the Bag of Words implementation of OpenCV 2.2.

The Bag of Words model for classification

The Bag of Words model (BoW) originated in natural language processing. It makes the simplifying assumption, that the order of the words in a sentence or text document is of negligible importance for classifying it. To describe a document with the BoW model, as a first step a dictionary containing a large number of words relevant to the application domain has to be created. If the goal is to classify conference papers then this could be done by analyzing hundreds or thousands of conference papers (the training set), from the different classes which the classifier should be able to distinguish, for relevant words. Relevant words are of course words which have a high probability of being contained in one class of texts and a low probability of being contained in others. Once the dictionary has been built it is possible to describe a document in terms of word counts. The vector describing the document has a length equal to the number of words in the dictionary and each dimension represents the number of occurrences of a certain word in the document. Continue reading →