LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ HOG feature vector

 

HOG feature vector.pngA 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? 

0 Kudos
Message 1 of 6
(2,535 Views)

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.

 

The manual doesn't mention how the output is organized, but often those kind of things are related to the actual measurement, so anyone familiar to HOG feature extraction (TL;DR) would probably know.

0 Kudos
Message 2 of 6
(2,485 Views)

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. 

0 Kudos
Message 3 of 6
(2,477 Views)

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. 

0 Kudos
Message 4 of 6
(2,474 Views)

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

"

0 Kudos
Message 5 of 6
(2,470 Views)

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.

0 Kudos
Message 6 of 6
(2,463 Views)