1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| function GA=filtre_gausse(M)
I=imread(M);
R=I(:,:,1);
G=I(:,:,2);
B=I(:,:,3);
IN=rgb2gray(I);
[a,b]=size(IN);
R=floor(double(R));
G=floor(double(G));
B=floor(double(B));
GA=[zeros(a-2,b-2),zeros(a-2,b-2),zeros(a-2,b-2)];
for x=2:a-1;
for y=2:b-1;
GA(x-1,y-1,1)=uint8(double((R(x-1,y-1)+R(x,y-1)+R(x+1,y-1)+R(x-1,y)+R(x,y)+R(x+1,y)+R(x-1,y+1)+R(x,y+1)+R(x+1,y+1))/9));
GA(x-1,y-1,2)=uint8(double((G(x-1,y-1)+G(x,y-1)+G(x+1,y-1)+G(x-1,y)+G(x,y)+G(x+1,y)+G(x-1,y+1)+G(x,y+1)+G(x+1,y+1))/9));
GA(x-1,y-1,3)=uint8(double((B(x-1,y-1)+B(x,y-1)+B(x+1,y-1)+B(x-1,y)+B(x,y)+B(x+1,y)+B(x-1,y+1)+B(x,y+1)+B(x+1,y+1))/9));
end
end
subplot(121);imshow(I);title('image _ M');
subplot(122);imshow(GA);title('image _ GR'); |
Partager