help-octave
[Top][All Lists]

replacing matlab's extractHOGFeatures with another HOG function

 From: welinton Subject: replacing matlab's extractHOGFeatures with another HOG function Date: Sat, 6 May 2017 00:40:01 -0700 (PDT)

0 down vote favorite

I downloaded some matlab code that I wish to run, but I do not have a
function used by the code, called  "extractHOGFeatures" that is being used
in this piece of code:

[hog_14x14, vis14x14] = extractHOGFeatures(img,'CellSize',[14 14]);

So I decided to find another code to replace it, and found this function to
do so:

function H=HOG(Im)
nwin_x=3;%set here the number of HOG windows per bound box
nwin_y=3;
B=9;%set here the number of histogram bins
[L,C]=size(Im); % L num of lines ; C num of columns
H=zeros(nwin_x*nwin_y*B,1); % column vector with zeros
m=sqrt(L/2);
if C==1 % if num of columns==1
Im=im_recover(Im,m,2*m);%verify the size of image, e.g. 25x50
L=2*m;
C=m;
end
Im=double(Im);
step_x=floor(C/(nwin_x+1));
step_y=floor(L/(nwin_y+1));
cont=0;
hx = [-1,0,1];
hy = -hx';
for n=0:nwin_y-1
for m=0:nwin_x-1
cont=cont+1;
angles2=angles(n*step_y+1:(n+2)*step_y,m*step_x+1:(m+2)*step_x);
magnit2=magnit(n*step_y+1:(n+2)*step_y,m*step_x+1:(m+2)*step_x);
v_angles=angles2(:);
v_magnit=magnit2(:);
K=max(size(v_angles));
%assembling the histogram with 9 bins (range of 20 degrees per bin)
bin=0;
H2=zeros(B,1);
for ang_lim=-pi+2*pi/B:2*pi/B:pi
bin=bin+1;
for k=1:K
if v_angles(k)<ang_lim
v_angles(k)=100;
H2(bin)=H2(bin)+v_magnit(k);
end
end
end

H2=H2/(norm(H2)+0.01);
H((cont-1)*B+1:cont*B,1)=H2;
end
end

My doubt is if I can use this function to replace extractHogFeatures with
it. My first thought is that no, because extractHOGFeatures is being used to
return a matrix as far as I understand, while this function only returns a
single dimension vector (H). Also, I am not sure with which values I could
replace the parameters that are being passed to extractHOGFeatures. Should I
replace:

'CellSize',[14 14]

with:

nwin_x and nwin_y?

Thanks for any help.

--
View this message in context:
http://octave.1599824.n4.nabble.com/replacing-matlab-s-extractHOGFeatures-with-another-HOG-function-tp4683199.html
Sent from the Octave - General mailing list archive at Nabble.com.

reply via email to