Skip to content

Commit

Permalink
some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Vondrick committed Nov 29, 2012
1 parent b583afc commit 030863d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 58 deletions.
8 changes: 2 additions & 6 deletions README.md
Expand Up @@ -26,12 +26,8 @@ We also provide a variety of visualization functions for HOG. The most basic is
>> feat = features(im, 8);
>> visualizeHOG(feat);

which will display a figure with the HOG glyph and the HOG inverse. You can optionally
pass a verbose flag to 'visualizeHOG()' to show more:

>>> visualizeHOG(feat, true);

which will display a figure with a zero meaned HOG visualization and a
which will display a figure with the HOG glyph and the HOG inverse. This
visualization is a drop-in replacement for more standard visualizations.

Installation
------------
Expand Down
8 changes: 5 additions & 3 deletions demo.m
Expand Up @@ -3,14 +3,16 @@
ihog = invertHOG(feat);

figure(1);
clf;

subplot(131);
imagesc(im); axis image;
imagesc(im); axis image; axis off;
title('Original Image', 'FontSize', 20);

subplot(132);
showHOG(feat);
showHOG(feat); axis off;
title('HOG Features', 'FontSize', 20);

subplot(133);
imagesc(ihog); axis image;
imagesc(ihog); axis image; axis off;
title('HOG Inverse', 'FontSize', 20);
71 changes: 22 additions & 49 deletions visualizations/visualizeHOG.m
Expand Up @@ -8,68 +8,41 @@
% >> visualizeHOG(feat);
%
% and the current figure will contain both the standard HOG glyph visualization as well
% as the inverse. This function has extra verbosity outputs you can use too:
% as the inverse.
%
% >> visualizeHOG(feat, 1)
%
% which will show a zero-mean HOG glyph and as well a spatial histogram of the texture
% features for HOG.
% If 'feat' has negative values, a second row will appear of the negatives.

function visualizeHOG(feat, verbosity),
function visualizeHOG(feat),

if ~exist('verbosity', 'var'),
verbosity = 0;
end

if verbosity == 0,
nfigs = 1;
else,
nfigs = 2;
end
s = [size(feat,1)*8+16 size(feat,2)*8+16];

im = invertHOG(max(feat, 0));
hog = HOGpicture(feat);
hog = imresize(hog, s);
hog(hog > 1) = 1;
hog(hog < 0) = 0;

buff = 5;
im = padarray(im, [buff buff], 0.5, 'both');
hog = padarray(hog, [buff buff], 0.5, 'both');

if min(feat(:)) < 0,
buff = 5;
hogneg = HOGpicture(-feat);
hogneg = imresize(hogneg, s);
hogneg(hogneg > 1) = 1;
hogneg(hogneg < 0) = 0;
hogneg = padarray(hogneg, [buff buff], 0.5, 'both');

neg = invertHOG(max(-feat, 0));
neg = padarray(neg, [buff buff], 0.5, 'both');
im = padarray(im, [buff buff], 0.5, 'both');

im = [im neg];
im = [im; neg];
hog = [hog; hogneg];
end

clf;

subplot(nfigs,2,1);
showHOG(feat);
title('HOG');
im = [im hog];

subplot(nfigs,2,2);
imagesc(im);
axis image;
axis off;
colormap gray;
title('Inverse');

if nfigs == 1,
return;
end

subplot(nfigs,2,3);
showHOG(feat - mean(feat(:)));
title('0-mean HOG');

subplot(nfigs,2,4);

if min(feat(:)) < 0,
buff = 5;
pos = HOGtexture(max(feat, 0));
pos = padarray(pos, [buff buff], 0.5, 'both');
neg = HOGtexture(max(-feat, 0));
neg = padarray(neg, [buff buff], 0.5, 'both');
imagesc([pos neg]);
else,
imagesc(HOGtexture(feat));
end

axis image;
title('HOG Texture');

0 comments on commit 030863d

Please sign in to comment.