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
| clear all
close all
clc
%Déclaration des variables
taille=31;
val=(taille-1)/2;
nbadventis=0; %nb adventices initialisé a zero
%Matrice circulaire
SE=strel('disk',16,0);
A=zeros(taille,taille);
A(val+1,val+1)=1;
imc=imdilate(A,SE);
taille_imc=size(imc)
Y=taille_imc(2);
X=taille_imc(1);
figure
subplot(1,2,1)
imshow(A)
subplot(1,2,2)
imshow(imc)
%%Image a traiter, variable
img=imread('mahala_filtre.bmp');
taille_img=size(img)
y=taille_img(2);
x=taille_img(1);
img1=img(:,:,1);
%%Balayage et corrélation
res1=zeros(size(x),size(y));% matrice de correlation
init=zeros(size(x),size(y));% matrice d'initialisation
for i=1:size(x)-taille
for j=1:size(Y):size(y)-taille
res1(i,j)=corr2(imc,img1);
if res1>=0,60
nbadventis=nbadventis+1
init(i,j)=init(i,j)+res(i,j);
i=i+size(X)
else i=i+1;
end
end
end
figure
subplot(1,2,1)
imshow(img1)
subplot(1,2,2)
imshow(init) |
Partager