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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
img=imread(I);
% detection de l'objet cad boite englobante pour extraire seulement mon objet .NB: l'image avec un fond noir
contour=im2bw(img);
[n,m]=size(contour);
a=[];
o=[];
h=1;
for i=1:n
for j=1:m
if(contour(i,j)==1)
a(h)=j;
o(h)=i;
h=h+1;
end;
end;
end;
maxa=max(a);
mina=min(a);
maxo=max(o);
mino=min(o);
contour=contour(mino:maxo,mina:maxa);
%transfome l'objet en noir et blanc
[m,n]=size(contour);
for i=1:m
for j=1:n
if contour(i,j) == 1
contour(i,j)=0;
else
contour(i,j)=1;
end;
end;
end;
un=contour;
%redimensionner l'objet
contour= imresize(un,[240 272],'bicubic');
%detection du contour
contour=edge(contour,'canny');
%calcule du descipteur de fourier
FF=fft2(contour);
fft_a2=fftshift(FF);
amp=abs(fft_a2);
R=[];
for i=1:size(amp)
R=[R amp(i,:)];
end
R = R(:);
R=R/sum(R);F=R;
%F contien notre descripteur |
Partager