# 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 ?