Permalink
Browse files

some tweaks

  • Loading branch information...
1 parent b583afc commit 030863dce32bff4b5cd6325bc1d6b9544be34426 @cvondrick cvondrick committed Nov 29, 2012
Showing with 29 additions and 58 deletions.
  1. +2 −6 README.md
  2. +5 −3 demo.m
  3. +22 −49 visualizations/visualizeHOG.m
View
@@ -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
------------
View
8 demo.m
@@ -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);
@@ -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.