# Histogram of Gradients - Integral Image method

I am trying to extract the histogram of oriented gradients for all the bounding boxes (approximately 1000) that I have in an image. This will be a very simplified version with only a single block per sub-image. I was wondering if anyone can comment on whether my implementation below can be sped up.

My current plan is to compute the magnitude and angle of the edge map dx and dy.

//compute magnitude and angle
cv::Mat mag, angle;
cv::cartToPolar(dx, dy, mag, angle, true);


Then I will create a vector of 9 matrices where each will store the magnitude for a range of angles eg. 0 - 20, 20 - 40, all the way up till 140 - 160. I will then run the integral image operation on these set of matrices and from there on, I can easily compute the histogram of oriented gradients. Is this too time consuming ? Are there any faster implementations ?

edit retag close merge delete

Sort by » oldest newest most voted

If there are lots of overlaps between your bounding boxes, that's a good idea. Otherwise there's no reason to bother with the integral image.

I would use the inRange function to make a a mask out of angle for each bin. The mask would then be an input of mag.copyTo(bin[x], mask);

As a bonus, if you need to, you could divide your boxes into more blocks with only a little more computation.

more

Official site

GitHub

Wiki

Documentation