Bag-of-words model in computer vision explained
In computer vision, the bag-of-words model (BoW model) sometimes called bag-of-visual-words model [1] [2] can be applied to image classification or retrieval, by treating image features as words. In document classification, a bag of words is a sparse vector of occurrence counts of words; that is, a sparse histogram over the vocabulary. In computer vision, a bag of visual words is a vector of occurrence counts of a vocabulary of local image features.
Image representation based on the BoW model
To represent an image using the BoW model, an image can be treated as a document. Similarly, "words" in images need to be defined too. To achieve this, it usually includes following three steps: feature detection, feature description, and codebook generation. [1] [2] [3] A definition of the BoW model can be the "histogram representation based on independent features".[4] Content based image indexing and retrieval (CBIR) appears to be the early adopter of this image representation technique.[5]
Feature representation
After feature detection, each image is abstracted by several local patches. Feature representation methods deal with how to represent the patches as numerical vectors. These vectors are called feature descriptors. A good descriptor should have the ability to handle intensity, rotation, scale and affine variations to some extent. One of the most famous descriptors is the scale-invariant feature transform (SIFT).[6] SIFT converts each patch to 128-dimensional vector. After this step, each image is a collection of vectors of the same dimension (128 for SIFT), where the order of different vectors is of no importance.
Codebook generation
The final step for the BoW model is to convert vector-represented patches to "codewords" (analogous to words in text documents), which also produces a "codebook" (analogy to a word dictionary). A codeword can be considered as a representative of several similar patches. One simple method is performing k-means clustering over all the vectors.[7] Codewords are then defined as the centers of the learned clusters. The number of the clusters is the codebook size (analogous to the size of the word dictionary).
Thus, each patch in an image is mapped to a certain codeword through the clustering process and the image can be represented by the histogram of the codewords.
Learning and recognition based on the BoW model
Computer vision researchers have developed several learning methods to leverage the BoW model for image related tasks, such as object categorization. These methods can roughly be divided into two categories, unsupervised and supervised models. For multiple label categorization problem, the confusion matrix can be used as an evaluation metric.
Unsupervised models
Here are some notations for this section. Suppose the size of codebook is
.
: each patch
is a V-dimensional vector that has a single component equal to one and all other components equal to zero (For k-means clustering setting, the single component equal one indicates the cluster that
belongs to). The
th codeword in the codebook can be represented as
and
for
.
: each image is represented by
, all the patches in an image
: the
th image in an image collection
: category of the image
: theme or topic of the patch
: mixture proportion
Since the BoW model is an analogy to the BoW model in NLP, generative models developed in text domains can also be adapted in computer vision. Simple Naive Bayes model and hierarchical Bayesian models are discussed.
Naive Bayes
The simplest one is Naive Bayes classifier.[2] Using the language of graphical models, the Naive Bayes classifier is described by the equation below. The basic idea (or assumption) of this model is that each category has its own distribution over the codebooks, and that the distributions of each category are observably different. Take a face category and a car category for an example. The face category may emphasize the codewords which represent "nose", "eye" and "mouth", while the car category may emphasize the codewords which represent "wheel" and "window". Given a collection of training examples, the classifier learns different distributions for different categories. The categorization decision is made by
c*=\argmaxcp(c|w)=\argmaxcp(c)p(w|c)=\argmaxc
Since the Naive Bayes classifier is simple yet effective, it is usually used as a baseline method for comparison.
Hierarchical Bayesian models
The basic assumption of Naive Bayes model does not hold sometimes. For example, a natural scene image may contain several different themes.Probabilistic latent semantic analysis (pLSA)[8] [9] and latent Dirichlet allocation (LDA)[10] are two popular topic models from text domains to tackle the similar multiple "theme" problem. Take LDA for an example. To model natural scene images using LDA, an analogy is made with document analysis:
- the image category is mapped to the document category;
- the mixture proportion of themes maps the mixture proportion of topics;
- the theme index is mapped to topic index;
- the codeword is mapped to the word.
This method shows very promising results in natural scene categorization on 13 Natural Scene Categories.[3]
Supervised models
Since images are represented based on the BoW model, any discriminative model suitable for text document categorization can be tried, such as support vector machine (SVM)[2] and AdaBoost.[11] Kernel trick is also applicable when kernel based classifier is used, such as SVM. Pyramid match kernel is newly developed one based on the BoW model. The local feature approach of using BoW model representation learnt by machine learning classifiers with different kernels (e.g., EMD-kernel and
kernel) has been vastly tested in the area of texture and object recognition.
[12] Very promising results on a number of datasets have been reported. This approach
[12] has achieved very impressive results in
the PASCAL Visual Object Classes Challenge.
Pyramid match kernel
Pyramid match kernel[13] is a fast algorithm (linear complexity instead of classic one in quadratic complexity) kernel function (satisfying Mercer's condition) which maps the BoW features, or set of features in high dimension, to multi-dimensional multi-resolution histograms. An advantage of these multi-resolution histograms is their ability to capture co-occurring features. The pyramid match kernel builds multi-resolution histograms by binning data points into discrete regions of increasing size. Thus, points that do not match at high resolutions have the chance to match at low resolutions. The pyramid match kernel performs an approximate similarity match, without explicit search or computation of distance. Instead, it intersects the histograms to approximate the optimal match. Accordingly, the computation time is only linear in the number of features. Compared with other kernel approaches, the pyramid match kernel is much faster, yet provides equivalent accuracy. The pyramid match kernel was applied to ETH-80 database and Caltech 101 database with promising results.[13] [14]
Limitations and recent developments
One of the notorious disadvantages of BoW is that it ignores the spatial relationships among the patches, which are very important in image representation. Researchers have proposed several methods to incorporate the spatial information. For feature level improvements, correlogram features can capture spatial co-occurrences of features.[15] For generative models, relative positions[16] [17] of codewords are also taken into account. The hierarchical shape and appearance model for human action[18] introduces a new part layer (Constellation model) between the mixture proportion and the BoW features, which captures the spatial relationships among parts in the layer. For discriminative models, spatial pyramid match[19] performs pyramid matching by partitioning the image into increasingly fine sub-regions and compute histograms of local features inside each sub-region. Recently, an augmentation of local image descriptors (i.e. SIFT) by their spatial coordinates normalised by the image width and height have proved to be a robust and simple Spatial Coordinate Coding[20] [21] approach which introduces spatial information to the BoW model.
The BoW model has not been extensively tested yet for view point invariance and scale invariance, and the performance is unclear. Also the BoW model for object segmentation and localization is not well understood.[4]
A systematic comparison of classification pipelines found that the encoding of first and second order statistics (Vector of Locally Aggregated Descriptors (VLAD)[22] and Fisher Vector (FV)) considerably increased classification accuracy compared to BoW, while also decreasing the codebook size, thus lowering the computational effort for codebook generation.[23] Moreover, a recent detailed comparison of coding and pooling methods[21] for BoW has showed that second order statistics combined with Sparse Coding and an appropriate pooling such as Power Normalisation can further outperform Fisher Vectors and even approach results of simple models of Convolutional Neural Network on some object recognition datasets such as Oxford Flower Dataset 102.
See also
External links
Notes and References
- 2003 . Video Google: A Text Retrieval Approach to Object Matching in Videos . 13-16 October 2003 .
- G. Csurka . C. Dance . L.X. Fan . J. Willamowski . C. Bray . amp . Visual categorization with bags of keypoints . Proc. of ECCV International Workshop on Statistical Learning in Computer Vision . 2004 .
- Book: 10.1109/CVPR.2005.16. 2005. Fei-Fei Li. Perona. P.. 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'05). A Bayesian Hierarchical Model for Learning Natural Scene Categories. 978-0-7695-2372-9. 2. 524–531. 6387937.
- Web site: L. Fei-Fei . R. Fergus . A. Torralba . amp . Recognizing and Learning Object Categories, CVPR 2007 short course .
- 10.1016/S0031-3203(01)00162-5. Indexing chromatic and achromatic patterns for content-based colour image retrieval. 1675–1686. 2002. Qiu. G.. Pattern Recognition. 35. 8. 2002PatRe..35.1675Q.
- Book: http://www.cs.ubc.ca/~lowe/papers/iccv99.pdf . 1150–1157 . 1999. 10.1109/ICCV.2003.1238356 . Object recognition with informative features and linear classification . Proceedings Ninth IEEE International Conference on Computer Vision . Vidal-Naquet . Ullman . 978-0-7695-1950-0 . 10.1.1.131.1283 . 15620181 .
- T. Leung . J. Malik . Jitendra Malik. Representing and recognizing the visual appearance of materials using three-dimensional textons . International Journal of Computer Vision . 43 . 1 . 29–44 . 2001 . 10.1023/A:1011126920638 . 14915716 .
- T. Hoffman . Probabilistic Latent Semantic Analysis . Proc. of the Fifteenth Conference on Uncertainty in Artificial Intelligence . 1999 . 2007-12-10 . https://web.archive.org/web/20070710083034/http://www.cs.brown.edu/~th/papers/Hofmann-UAI99.pdf . 2007-07-10 . dead.
- Book: 10.1109/ICCV.2005.77 . Tenth IEEE International Conference on Computer Vision (ICCV'05) Volume 1 . http://www.robots.ox.ac.uk/~vgg/publications/papers/sivic05b.pdf . Discovering objects and their location in images . 2005 . Sivic . J. . Russell . B.C. . Efros . A.A. . Zisserman . A. . Freeman . W.T. . 978-0-7695-2334-7 . 370 . 10.1.1.184.1253 . 206769491 . 2007-12-10 . 2020-01-31 . https://web.archive.org/web/20200131172436/http://www.robots.ox.ac.uk/~vgg/publications/papers/sivic05b.pdf . dead.
- D. Blei . A. Ng . M. Jordan . amp . Latent Dirichlet allocation . Journal of Machine Learning Research . 3 . 993–1022 . 2003 . 10.1162/jmlr.2003.3.4-5.993 . Lafferty . John . 4–5 . 2007-12-10 . https://web.archive.org/web/20080822212053/http://www.cs.princeton.edu/~blei/papers/BleiNgJordan2003.pdf . 2008-08-22 . dead.
- Book: 10.1109/CVPR.2005.254 . http://cbcl.mit.edu/projects/cbcl/publications/ps/serre-PID73457-05.pdf . Object Recognition with Features Inspired by Visual Cortex . 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'05) . 2005 . Serre . T. . Wolf . L. . Poggio . T. . 978-0-7695-2372-9 . 2 . 994 . 10.1.1.71.5276 . 260426 . 2007-12-10 . 2017-07-06 . https://web.archive.org/web/20170706051952/http://cbcl.mit.edu/projects/cbcl/publications/ps/serre-PID73457-05.pdf . dead .
- Jianguo Zhang . Marcin Marszałek . Svetlana Lazebnik. Svetlana Lazebnik . Cordelia Schmid . Cordelia Schmid. Local Features and Kernels for Classification of Texture and Object Categories: a Comprehensive Study . International Journal of Computer Vision . 2007. 73 . 2 . 213–238 . 10.1007/s11263-006-9794-4. 1486613 .
- Book: 10.1109/ICCV.2005.239 . http://www.cs.utexas.edu/~grauman/papers/grauman_darrell_iccv2005.pdf . The pyramid match kernel: discriminative classification with sets of image features . Tenth IEEE International Conference on Computer Vision (ICCV'05) Volume 1 . 2005 . Grauman . K. . Darrell . T. . 978-0-7695-2334-7 . 1458. 10.1.1.644.6159 . 13036203 .
- Book: http://www.ifp.illinois.edu/~jyang29/ScSPM.htm. 10.1109/CVPR.2009.5206757. Linear spatial pyramid matching using sparse coding for image classification. 2009 IEEE Conference on Computer Vision and Pattern Recognition. 2009. Jianchao Yang. Kai Yu. Yihong Gong. Huang. T.. 978-1-4244-3992-8. 1794. 440212. 2011-09-09. 2019-03-20. https://web.archive.org/web/20190320012627/http://www.ifp.illinois.edu/~jyang29/ScSPM.htm. dead.
- Book: 10.1109/CVPR.2006.102 . http://johnwinn.org/Publications/papers/Savarese_Winn_Criminisi_Correlatons_CVPR2006.pdf . 2006 . Discriminative Object Class Models of Appearance and Shape by Correlatons . 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition - Volume 2 (CVPR'06) . Savarese . S. . Winn . J. . Criminisi . A. . 978-0-7695-2597-6 . 2 . 2033 . 10.1.1.587.8853 . 1457124 . 2007-12-10 . 2013-10-29 . https://web.archive.org/web/20131029185403/http://johnwinn.org/Publications/papers/Savarese_Winn_Criminisi_Correlatons_CVPR2006.pdf . dead .
- Book: 10.1109/ICCV.2005.137. http://ssg.mit.edu/~esuddert/papers/iccv05.pdf. Learning hierarchical models of scenes, objects, and parts. Tenth IEEE International Conference on Computer Vision (ICCV'05) Volume 1. 2005. Sudderth. E.B.. Torralba. A.. Freeman. W.T.. Willsky. A.S.. 978-0-7695-2334-7. 1331. 10.1.1.128.7259. 6153430. 2007-12-10. 2019-02-03. https://web.archive.org/web/20190203220118/http://ssg.mit.edu/~esuddert/papers/iccv05.pdf. dead.
- E. Sudderth . A. Torralba . W. Freeman . A. Willsky . amp . Describing Visual Scenes using Transformed Dirichlet Processes . Proc. of Neural Information Processing Systems . 2005 .
- Book: 10.1109/CVPR.2007.383132. http://vision.stanford.edu/posters/NieblesFeiFei_CVPR07_poster.pdf . 2007. A Hierarchical Model of Shape and Appearance for Human Action Classification. 2007 IEEE Conference on Computer Vision and Pattern Recognition. Niebles. Juan Carlos. Li Fei-Fei. 978-1-4244-1179-5. 1 . 10.1.1.173.2667 . 9213242 .
- Book: 10.1109/CVPR.2006.68. http://www-cvr.ai.uiuc.edu/ponce_grp/publication/paper/cvpr06b.pdf. 2006. Beyond Bags of Features: Spatial Pyramid Matching for Recognizing Natural Scene Categories. 2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition - Volume 2 (CVPR'06). Lazebnik. S.. Svetlana Lazebnik. Schmid. C.. Cordelia Schmid. Ponce. J.. 978-0-7695-2597-6. 2. 2169. 10.1.1.651.9183. 2421251. 2007-12-10. 2018-05-08. https://web.archive.org/web/20180508181616/http://www-cvr.ai.uiuc.edu/ponce_grp/publication/paper/cvpr06b.pdf. dead.
- Koniusz. Piotr. Yan. Fei. Mikolajczyk. Krystian. 2013-05-01. Comparison of mid-level feature coding approaches and pooling strategies in visual concept detection. Computer Vision and Image Understanding. 117. 5. 479–492. 10.1016/j.cviu.2012.10.010. 1077-3142.
- Koniusz. Piotr. Yan. Fei. Gosselin. Philippe Henri. Mikolajczyk. Krystian. 2017-02-24. Higher-order occurrence pooling for bags-of-words: Visual concept detection. IEEE Transactions on Pattern Analysis and Machine Intelligence. 39. 2. 313–326. 10.1109/TPAMI.2016.2545667. 27019477. 0162-8828. 10044/1/39814. free.
- Book: Jégou. H.. Douze. M.. Schmid. C.. Pérez. P.. 2010 IEEE Computer Society Conference on Computer Vision and Pattern Recognition . Aggregating local descriptors into a compact image representation . 2010-06-01. 3304–3311. 10.1109/CVPR.2010.5540039. 978-1-4244-6984-0. 1912782.
- Seeland. Marco. Rzanny. Michael. Alaqraa. Nedal. Wäldchen. Jana. Mäder. Patrick. 2017-02-24. Plant species classification using flower images—A comparative study of local feature representations. PLOS ONE. 12. 2. e0170629. 10.1371/journal.pone.0170629. 28234999. 5325198. 2017PLoSO..1270629S. 1932-6203. free.