Ask Your Question

Can the Bag of Words functions be used with binary descriptors?

asked 2012-09-25 09:17:18 -0600

excelerate gravatar image

Basically, I have a bunch of binary descriptors, and I want to use a bag of words model to transform them into a histogram, stemming from 100 clusters. I have coded this out by hand, but my hunch is that the OpenCV implementation is likely better coded and potentially well optimized, so I'd like to see if that yields more efficient computation.

So, with the descriptors already extracted (and binary), can the bag of words functions be used to cluster/assign to build the bag of words model on binary features?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-01-08 10:14:59 -0600

Guanta gravatar image

It seems that this is currently not possible since the K-Means used in BOWKMeansTrainer expects the data to be in float, i.e., you need to compute the uchar Cluster-Centers yourself which you can then add to your BOWImgDescriptorExtractor via setVocabulary(), the rest should then work fine.

edit flag offensive delete link more


How do you "compute the uchar Cluster-Centers yourself"?

fakeaccount gravatar imagefakeaccount ( 2015-02-04 07:09:27 -0600 )edit
  • Convert your data from uchar to float, then use normal k-means and (if needed) convert back to uchar
  • Better: Use k-medoids algorithm (not part of OpenCV) instead of k-means
Guanta gravatar imageGuanta ( 2015-02-05 02:02:49 -0600 )edit

I thought simply changing from uchar to float was a work around that didn't really work as it though it doesn't cause any errors, but doesn't run entirely properly either?

fakeaccount gravatar imagefakeaccount ( 2015-02-19 11:34:34 -0600 )edit

Yes, thus, you should better use k-medoids or another clustering method which can deal with binary data since norm-wise it would be a totally different world (Euclidean vs Hamming Norm). However, according to Muja (author of FLANN), you might use HierarchicalClusteringIndexParams for clustering binary data, see also this post: .

Guanta gravatar imageGuanta ( 2015-02-19 15:51:50 -0600 )edit

Question Tools



Asked: 2012-09-25 09:17:18 -0600

Seen: 1,668 times

Last updated: Jan 08 '13