I use the HOGDescriptor of the OpenCV C++ Lib to compute the feature vectors of an images. I would like to visualize the features in the source image. Can anyone help me?
问题:
回答1:
I had exactly the same problem today. Computing a HOGDescriptor
vector for a 64x128 image using OpenCV's HOGDescriptor::compute()
function is easy, but there is no built-in functionality to visualize it.
Finally I managed to understand how the gradient orientation magnitudes are stored in the 3870 long HOG descriptor vector.
You can find my C++ code for visualizing the HOGDescriptor
here:
Hope it helps!
Jürgen
回答2:
This visualization tool may be more useful than plotting the gradient vectors of HOG because one can see better why HOG failed for a given sample.
More information can be found here: http://web.mit.edu/vondrick/ihog/
回答3:
This opencv group discussion leads to a library written at Brown University.
In HOGpicture.m
you should be able to get an idea how to visualize the descriptors. Here is the relevant (matlab) code. Is it enough for you to make something for yourself?
(below code is released under an MIT license)
function im = HOGpicture(w, bs) % HOGpicture(w, bs) % Make picture of positive HOG weights. % construct a "glyph" for each orientation bim1 = zeros(bs, bs); bim1(:,round(bs/2):round(bs/2)+1) = 1; bim = zeros([size(bim1) 9]); bim(:,:,1) = bim1; for i = 2:9, bim(:,:,i) = imrotate(bim1, -(i-1)*20, 'crop'); end % make pictures of positive weights bs adding up weighted glyphs s = size(w); w(w