fhog

PURPOSE ^

FHOG Efficiently compute Felzenszwalb's HOG (FHOG) features.

SYNOPSIS ^

function H = fhog( I, binSize, nOrients, clip, crop )

DESCRIPTION ^

 FHOG Efficiently compute Felzenszwalb's HOG (FHOG) features.

 FHOG.m A fast implementation of the HOG variant used by Felzenszwalb et al.
 in their work on discriminatively trained deformable part models.
  http://www.cs.berkeley.edu/~rbg/latent/index.html
 Gives nearly identical results to features.cc in code release version 5
 but runs 4x faster (over 125 fps on VGA color images).

 The computed HOG features are 3*nOrients+5 dimensional. There are
 2*nOrients contrast sensitive orientation channels, nOrients contrast
 insensitive orientation channels, 4 texture channels and 1 all zeros
 channel (used as a 'truncation' feature). Using the standard value of
 nOrients=9 gives a 32 dimensional feature vector at each cell. This
 variant of HOG, refered to as FHOG, has been shown to achieve superior
 performance to the original HOG features. For details please refer to
 work by Felzenszwalb et al. (see link above).

 This function is essentially a wrapper for calls to gradientMag()
 and gradientHist(). Specifically, it is equivalent to the following:
  [M,O] = gradientMag( I,0,0,0,1 ); softBin = -1; useHog = 2;
  H = gradientHist(M,O,binSize,nOrients,softBin,useHog,clip);
 See gradientHist() for more general usage.

 This code requires SSE2 to compile and run (most modern Intel and AMD
 processors support SSE2). Please see: http://en.wikipedia.org/wiki/SSE2.

 USAGE
  H = fhog( I, [binSize], [nOrients], [clip], [crop] )

 INPUTS
  I        - [hxw] color or grayscale input image (must have type single)
  binSize  - [8] spatial bin size
  nOrients - [9] number of orientation bins
  clip     - [.2] value at which to clip histogram bins
  crop     - [0] if true crop boundaries

 OUTPUTS
  H        - [h/binSize w/binSize nOrients*3+5] computed hog features

 EXAMPLE
  I=imResample(single(imread('peppers.png'))/255,[480 640]);
  tic, for i=1:100, H=fhog(I,8,9); end; disp(100/toc) % >125 fps
  figure(1); im(I); V=hogDraw(H,25,1); figure(2); im(V)

 EXAMPLE
  % comparison to features.cc (requires DPM code release version 5)
  I=imResample(single(imread('peppers.png'))/255,[480 640]); Id=double(I);
  tic, for i=1:100, H1=features(Id,8); end; disp(100/toc)
  tic, for i=1:100, H2=fhog(I,8,9,.2,1); end; disp(100/toc)
  figure(1); montage2(H1); figure(2); montage2(H2);
  D=abs(H1-H2); mean(D(:))

 See also hog, hogDraw, gradientHist

 Piotr's Image&Video Toolbox      Version 3.23
 Copyright 2013 Piotr Dollar.  [pdollar-at-caltech.edu]
 Please email me if you find bugs, or have suggestions or questions!
 Licensed under the Simplified BSD License [see external/bsd.txt]

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function H = fhog( I, binSize, nOrients, clip, crop )
0002 % FHOG Efficiently compute Felzenszwalb's HOG (FHOG) features.
0003 %
0004 % FHOG.m A fast implementation of the HOG variant used by Felzenszwalb et al.
0005 % in their work on discriminatively trained deformable part models.
0006 %  http://www.cs.berkeley.edu/~rbg/latent/index.html
0007 % Gives nearly identical results to features.cc in code release version 5
0008 % but runs 4x faster (over 125 fps on VGA color images).
0009 %
0010 % The computed HOG features are 3*nOrients+5 dimensional. There are
0011 % 2*nOrients contrast sensitive orientation channels, nOrients contrast
0012 % insensitive orientation channels, 4 texture channels and 1 all zeros
0013 % channel (used as a 'truncation' feature). Using the standard value of
0014 % nOrients=9 gives a 32 dimensional feature vector at each cell. This
0015 % variant of HOG, refered to as FHOG, has been shown to achieve superior
0016 % performance to the original HOG features. For details please refer to
0017 % work by Felzenszwalb et al. (see link above).
0018 %
0019 % This function is essentially a wrapper for calls to gradientMag()
0020 % and gradientHist(). Specifically, it is equivalent to the following:
0021 %  [M,O] = gradientMag( I,0,0,0,1 ); softBin = -1; useHog = 2;
0022 %  H = gradientHist(M,O,binSize,nOrients,softBin,useHog,clip);
0023 % See gradientHist() for more general usage.
0024 %
0025 % This code requires SSE2 to compile and run (most modern Intel and AMD
0026 % processors support SSE2). Please see: http://en.wikipedia.org/wiki/SSE2.
0027 %
0028 % USAGE
0029 %  H = fhog( I, [binSize], [nOrients], [clip], [crop] )
0030 %
0031 % INPUTS
0032 %  I        - [hxw] color or grayscale input image (must have type single)
0033 %  binSize  - [8] spatial bin size
0034 %  nOrients - [9] number of orientation bins
0035 %  clip     - [.2] value at which to clip histogram bins
0036 %  crop     - [0] if true crop boundaries
0037 %
0038 % OUTPUTS
0039 %  H        - [h/binSize w/binSize nOrients*3+5] computed hog features
0040 %
0041 % EXAMPLE
0042 %  I=imResample(single(imread('peppers.png'))/255,[480 640]);
0043 %  tic, for i=1:100, H=fhog(I,8,9); end; disp(100/toc) % >125 fps
0044 %  figure(1); im(I); V=hogDraw(H,25,1); figure(2); im(V)
0045 %
0046 % EXAMPLE
0047 %  % comparison to features.cc (requires DPM code release version 5)
0048 %  I=imResample(single(imread('peppers.png'))/255,[480 640]); Id=double(I);
0049 %  tic, for i=1:100, H1=features(Id,8); end; disp(100/toc)
0050 %  tic, for i=1:100, H2=fhog(I,8,9,.2,1); end; disp(100/toc)
0051 %  figure(1); montage2(H1); figure(2); montage2(H2);
0052 %  D=abs(H1-H2); mean(D(:))
0053 %
0054 % See also hog, hogDraw, gradientHist
0055 %
0056 % Piotr's Image&Video Toolbox      Version 3.23
0057 % Copyright 2013 Piotr Dollar.  [pdollar-at-caltech.edu]
0058 % Please email me if you find bugs, or have suggestions or questions!
0059 % Licensed under the Simplified BSD License [see external/bsd.txt]
0060 
0061 %Note: modified to be more self-contained
0062 
0063 if( nargin<2 ), binSize=8; end
0064 if( nargin<3 ), nOrients=9; end
0065 if( nargin<4 ), clip=.2; end
0066 if( nargin<5 ), crop=0; end
0067 
0068 softBin = -1; useHog = 2; b = binSize;
0069 
0070 [M,O]=gradientMex('gradientMag',I,0,1);
0071 
0072 H = gradientMex('gradientHist',M,O,binSize,nOrients,softBin,useHog,clip);
0073 
0074 if( crop ), e=mod(size(I),b)<b/2; H=H(2:end-e(1),2:end-e(2),:); end
0075 
0076 end

Generated on Thu 24-Nov-2016 18:03:21 by m2html © 2005