Histograms of Oriented Gradient
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all I have applied HOG into a video sequence without SVM classifier.But I am not getting any result.my code is here.
clc;
close all;
source='campus_raw.AVI';
vidobj=videoreader(source);
Height=vidobj.Height;
Width=vidobj.width;
frames=vidobj.NumberOfFrames;
threshold=10;
nbins=9;
for f=1:frames
thisframe=read(vidobj,f);
figure(1);imshow(thisframe);
[Rows Cols Colors]=size(thisframe);
nwin_x=3;
nwin_y=3;
H=zeros(nwin_x*nwin_y*nbins);
m=sqrt(Rows/2);
step_x=floor(m/(nwin_x+1));
step_y=floor(m/(nwin_y+1));
cont=0;
% Gamma/Color Normalization..
if Colors>1
GrayImage=rgb2gray(thisframe);
GrayImage=double(GrayImage);
else
GrayImage=thisframe;
end
% Gradient Computation
Gx=[-1 0 1];
Gy=-Gx;
Grad_ImageX=imfilter(double(GrayImage),Gx);
Grad_ImageY=imfilter(double(GrayImage),Gy);
MagImage=((Grad_ImageX.^2)+(Grad_ImageY)).^0.5;
%figure(3);imshow(MagImage);
DirImage=atan2(Grad_ImageY,Grad_ImageX);
%figure(4);imshow(DirImage);
nbins=9;
for n=0:nwin_y-1
for m=0:nwin_x-1
cont=cont+1;
DirImage1=DirImage(n*step_y+1:(n+2)*step_y,m*step_x+1:(m+2)*step_x);
MagImage1=MagImage(n*step_y+1:(n+2)*step_y,m*step_x+1:(m+2)*step_x);
v_angles=DirImage1(:);
v_magnit=MagImage1(:);
K=max(size(v_angles));
B=0;
Hist=zeros(nbins,1);
for ang_lim=-pi+2*pi/nbins:2*pi/nbins:pi;
B=B+1;
for k=1:K
if v_angles(k)<ang_lim
v_angles(k)=100;
Hist(B)=Hist(B)+v_magnit(k);
end
end
end
Hist=Hist/(norm(Hist)+0.01);
H((cont-1)*nbins+1:cont*nbins,1)=Hist;
end
figure(3);imshow(Hist(B));
end
end
figure(3);imshow(Hist(B)) shows nothing to me.Why?Any help please.
Thanks .
0 commentaires
Réponses (1)
Walter Roberson
le 3 Jan 2013
You are using B as a counter, and Hist is a vector, so Hist(B) would be a single element out of the vector. You then try to show that single element as if it were an entire image. If you are sure that is what you want, then what you probably need to do is change your imshow(Hist(B)) to imshow(Hist(B),[])
1 commentaire
Walter Roberson
le 3 Jan 2013
Please put a breakpoint in at the line
Hist(B)=Hist(B)+v_magnit(k);
and verify that you do reach that sometimes, and that the v_magnit(k) is non-zero.
Also, please go back through your code and indent it consistently. e.g., currently your "cont=cont+1;" line is indented at the same level as "for m". It is a strain to debug someone else's code when the indentation is inconsistent.
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!