A quick question about the HOG feature vector output.
I used the default 9 bin. I set the Grid Size to be 50 X 50, and the result vector size is 22500. The image size is 250 X 250.
I have a hard time to understand the structure of the feature vector? If I want map the feature vector to the image, how to parse the gigantic array?
what does the 'Grid Size' refer to? The cell size to calculate histogram of gradient?
Can't be a coincident that 9X50X50=22500... Apparently, you get 9 values for each cell in the 50X50 grid, or one big vector the size of bins X grid.
Thanks for help.
It certainly looks that way, 9 X 50 X 50. However, ( I should have done this when I sent the post), if I selected a grid size 40 X 40, the feature vector size is 15129, which is 9 X 41 X 41; for a grid szie 30 X 30, the feature vector size is 8649, 9 X 31 X 31. This is where it got me. The numbers just don't match.
Just a wild guess... Must be some rounding going on. For instance 50X50 fits 250X250 perfectly. 40X40 won't fit, so there will probably be a "left over" cell, the 41th.
You could test this with different image sizes, and\or different cell sizes (125, 25 and 10 should fit 250).
Calculating\predicting this is easy with Quotient & Remainder. 250%50, Q=5, R=0, 250%40 Q=6, R=10. So with 250 over 40, you get 40 cells of 6 pixels, and one of 10 pixels.
Not sure why the help doesn't mention things like this. Might have been be too advanced.
what you said is correct. I just checked the Help document. The Grid Size refers to how to divide the entire image. So 30 X 30 turns out be a 31 X 31 out of a 250 X 250 image.
Now the only question left is how the Feature Vector is structured? Row-based or column-based? In the help document, it only says "
Feature Vector contains the extracted features in the image
It could be one big vector, where all value relate to each other. I've never used HUG feature vectors before.
If there was a one-to-one relation to the grid, I'd expect a 2D array of clustered 1D array values. Then again, that might have been too much work or just unclear to the developer.
Guess you can find out, by changing the image one cell at the time, and see what values change. If it's grid related, once you know the grid size, conversion should be fairly easy with some reshape array\for loop magic.