Code covered by the BSD License  

Highlights from
HOG descriptor for Matlab

4.30769

4.3 | 13 ratings Rate this file 160 Downloads (last 30 days) File Size: 1.85 KB File ID: #28689

HOG descriptor for Matlab

by

 

11 Sep 2010 (Updated )

Image descriptor based on Histogram of Oriented Gradients for gray-level images

| Watch this File

File Information
Description

This code is simple and commented, what enables the adjust of the HOG parameters. This code was developed for the work: O. Ludwig, D. Delgado, V. Goncalves, and U. Nunes, 'Trainable Classifier-Fusion Schemes: An Application To Pedestrian Detection,' In: 12th International IEEE Conference On Intelligent Transportation Systems, 2009, St. Louis, 2009. V. 1. P. 432-437. In case of publication with this code, please cite the paper above.

MATLAB release MATLAB 7 (R14)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (28)
04 May 2014 Hisham Sager

After taking the HOG of a whole image, and taking the HOG of a 32x32 section, comparing the same location from the whole image HOG and the 32x32 HOG they are not the same. Even in the areas in the middle of the image which are far from the borders.
What is the reason?

31 Mar 2014 Akshay Gore  
04 Feb 2014 Izem

I think the code proposed by @Aaron is very helpful

28 May 2013 Pervukhina  
04 May 2013 Chris McCormick

I noticed a bug in the histogram computation. Gradient vectors whose angle is equal to pi are being omitted from the histogram because you check for angle < angle_lim instead of angle <= angle_lim.

I also re-wrote the histogram computation to optimize it in a way similar to what was suggested in an earlier comment.

% Compute the bin index for every angle.
binIndeces = ceil((v_angles + pi) / binSize);

% For each bin
for (bin = 1:B)
% Get the magnitudes for all the pixels that belong in 'bin'.
magnitudes = v_magnit(binIndeces == bin);

% Add all of the magnitudes to 'bin'.
H2(bin) = H2(bin) + sum(magnitudes);
end

14 Mar 2013 tamanna

@Oswaldo Ludwig sir, may i have your full paper coding ''Trainable Classifier-Fusion Schemes: An Application To Pedestrian Detection''

24 Jan 2013 Oswaldo Ludwig

Could you explain why it was adopted blockwise normalization? From the best of my knowledge, there is no mathematical foundation behind HOG descriptors, only good sense. This is my version, which was made available to be evaluated by the community. Go ahead, you should make the comparison with other algorithms in your case study (Science is not religion, feel free to doubt and inovate).

24 Jan 2013 Lukas Tencer

Also you are doing normalization of the final vector, originally it supposed to be blockwise normalization, did you try that version? Why you decided for normalization only of final histogram.

24 Jan 2013 Lukas Tencer

Should not be contribution of individual points to the histogram weighted according to gaussian centred in the middle of each cell?

07 Nov 2012 Algorithms Analyst

Can anyone help I am runiing this code but finding error?
Thanks inadvance

??? Input argument "Im" is undefined.

Error in ==> HOG at 11
[L,C]=size(Im); % L num of lines ; C num of columns

31 Oct 2012 PRAVEENKUMAR

sir,i run your code,i am getting the error

??? Input argument "Im" is undefined.

Error in ==> HOG at 11
[L,C]=size(Im); % L num of lines ; C num of columns

please help me to correct this.

19 Oct 2012 Raul  
09 Oct 2012 Alsam  
28 Sep 2012 saif

Can we use this code for object NOT human?

If I want to classify objects such as coca-cola and ketchup, can I do this directly with this code, I mean to use these features?

28 Sep 2012 Oswaldo Ludwig

Raul, the number of features depends on the number of cells and histograms bins, see Section II-A of this paper: http://www2.isr.uc.pt/~urbano/PDFs_PUB/Conferencias_Internacionais/2009/[113]2009ITSC09-129-FI.pdf

28 Sep 2012 Raul

I would like to know why the size of the HOG vector is the same for each image with different sizes.

27 Sep 2012 Prabhu  
20 Sep 2012 Aaron

replace lines 42-47 with code below for 20x speed-up

idx = find(v_angles<ang_lim);
v_angles(idx) = 100;
H2(bin) = H2(bin) + sum(v_magnit(idx));

08 Jun 2012 Stathis Fotiadis  
01 Jun 2012 Oswaldo Ludwig

An application for human detection (Windows only) can be found in http://webmail.isr.uc.pt/~oludwig/
The program is based on HOG descriptors for Matlab arranged in SRM-cascade, according to the methodology described in: O. Ludwig; “ Study on Non-parametric Methods for Fast Pattern Recognition with Emphasis on Neural Networks and Cascade Classifiers;” PhD Thesis, University of Coimbra, Coimbra, 2012. New images can be included in the folder "images" with the name "ped_XX". The algorithm was trained by using 18x36 gray-scale images from the Daimler Pedestrian Classification dataset. Double-click in detector_pkg.exe to install the program, then it is possible to run detector.exe.

14 Mar 2012 Swan

Hi,what is this section for?
if C==1
Im=im_recover(Im,m,2*m);
L=2*m;
C=m;
end
in what case, C==1?

06 Jan 2012 Caelyn Low  
27 Nov 2011 Aeris

Hi, do you have any example showing how the descriptor is applied to an 640x480 image?
And i don't really understand how does 2*pi/B = 360/9 => 20 degrees per bin? As i see it is equal to 40 degrees.
"ang_lim=-pi+2*pi/B:2*pi/B:pi"

Please correct me if i were wrong, thanks.

22 Nov 2011 Tom

Hello. Why in this case is use y filter hy=-hx' and not hy=hx'?

Thank you for your answer in advance.

Tom

03 Oct 2011 David Lewis  
17 Mar 2011 Oswaldo Ludwig

Dear Luis, you're right, a revised version was submitted.

16 Mar 2011 Luis Alejandro Fonseca Rodriguez

Hello, I have found a error in your HOG descriptor program, the magnitude is calculated wrong. You multiply when you should sum.

04 Nov 2010 Oswaldo Ludwig

We have achieved good result in object detection, regarding detection speed and accuracy, by combining this descriptor with NN trained by MMGDX, see:

http://www.mathworks.com/matlabcentral/fileexchange/28749-new-version-of-mmgdx-a-maximum-margin-training-method-for-neural-networks

Updates
17 Mar 2011

A problem in the calculation of gradient norm was corrected

Contact us