Ask Your Question
0

How to construct a histogram representation suitable for SVM classification

asked 2017-02-13 05:36:04 -0600

ElectronicEng2015 gravatar image

Hello everyone!,

I have been working recently with the BRISK algorithm. It generates descriptors of 64 bytes length for each keypoint. After implementing an algorithm based on K-medoids algorithm, I could assign each descriptor to its corresponding VISUAL WORD (centroid or medoid) based on the minimum Hamming distance when comparing with a set of randomly generated centroids.

Now that I have Identify each descriptor with its corresponding "Visual Word", I want to create a histogram where the bins correspond to those VISUAL WORDS and the values they can take correspond to the amount of descriptors contained in each cluster.

From this point, I need to generate the corresponding histogram to be used by a classification method such as SVM, for object recognition and detection purposes. I am currently using OpenCV 3.1, and for building a histogram I am not sure how to proceed.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-02-13 11:15:07 -0600

berak gravatar image

updated 2017-02-13 11:20:37 -0600

maybe you could look at opencv's bag of words implementation

you could do it like this:

   // this will be one row of your traindata.
   Mat histogram(1, num_clusters, CV_32F, 0.0f); 
   // * extract brisk features from your image, then
   // * match them to your kmedian clusters
   for (each match)
       histogram(matched_cluster_id) += 1;
   normalize(histogram, histogram);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-13 05:36:04 -0600

Seen: 340 times

Last updated: Feb 13 '17