Creating Polar Histogram on Contour Segment

asked 2017-03-01 23:49:37 -0600

jpistorino gravatar image

I am using OpenCV 3.1.1 on a Win10 64bit machine with C++.

I am attempting to implement the approach in Xingang, et al., "Bag of Contour Fragments for Robust Shape Classification" (2014). http://dl.acm.org/citation.cfm?id=258...

One aspect of that paper involves creating a sort of polar histogram of contour segments.

image description

On a contour segment, five points are picked. At each point, two histograms are/a single combined histogram is created: 1) the angle space is divided into 10 bins; and 2) the radius space is divided into 6 bins. This was done in Matlab which has a "polarhistogram" function that computes all of this.

My question is: what is the easiest way to do this in OpenCV?

Thanks for any help.

edit retag flag offensive close merge delete

Comments

1

one idea would be: split your contour into seperate x,y arrays, apply cartToPolar to get magnitude and angle, and then simply "bin" (or "quantify" ? what's the word here ?) those

berak gravatar imageberak ( 2017-03-02 02:25:32 -0600 )edit

Thanks Berak. This is the kind of thing I was struggling with. I was thinking that there might be some OpenCV counterpart to the Matlab "polarhistogram" that was no jumping out at me. Instead, I will just write my own.

jpistorino gravatar imagejpistorino ( 2017-03-02 18:27:37 -0600 )edit

Once you do have it, please submit a PR with the functioning code. This polarhistogram can be a step to implementing more techniques depending on this (and there are actually quite alot of those)!

StevenPuttemans gravatar imageStevenPuttemans ( 2017-03-03 08:44:59 -0600 )edit