-
Notifications
You must be signed in to change notification settings - Fork 0
/
hist_of_grad.m
34 lines (29 loc) · 1.01 KB
/
hist_of_grad.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function [FV]=hist_of_grad(mag,grad)
sz_mag=size(mag);
% feature vector size because (64/8) on the x axis and (128/8) on y axis
%9 because the gradient is divided into 9 parts [20 to 180]
FV=zeros(128,9);
m=1;
for i=1:8:sz_mag(1)
for j=1:8:sz_mag(2)
sum=zeros(1,9);
for k=i:i+7
for l=j:j+7
grad_sample=grad(k,l);
img_sample=mag(k,l);
[sum_FV1,sum_FV2,pos]=normalization_(grad_sample,img_sample);
sum(pos)=sum(pos)+sum_FV1;
if sum_FV2>0
if(pos==9)
sum(1)=sum(1)+sum_FV2;
else
sum(pos+1)=sum(pos+1)+sum_FV2;
end
end
end
end
FV(m,:)=sum;
m=m+1;
end
end
end