Smoothing Filter

%Smoothing Filter
f=imread('fig4.jpg');
f=double(f);
[m,n]=size(f);
g=zeros(m,n);
for x=2: m-1
    for y=2: n-1
        g(x,y)=(f(x-1,y-1)+f(x-1,y)+f(x-1,y+1)+f(x,y-1)+f(x,y)+f(x,y+1)+f(x+1,y-1)+f(x+1,y)+f(x+1,y+1))/9;
       
    end
end
f=mat2gray(f);
g=mat2gray(g);
subplot(1,2,1),imshow(f),title('input image');  
 subplot(1,2,2),imshow(g),title('smooth image'); 
Previous Post Next Post