MATLAB : Median filter for image restoration.
I'm trying to write a modified filter for image restoration. The code is
%start
A = imread('/*path name*/') ;
A = im2double(A);
[m n] = size(A);
Med = [];
%Modified filter
for i=2:m-1
for j=2:n-1
Med(1) = A(i-1,j-1);
Med(2) =A(i-1,j) ;
Med(3) = A(i-1,j+1);
Med(4) = A(i,j-1);
Med(5) = A(i,j+1);
Med(6) = A(i+1, j-1);
Med(7) = A(i+1,j);
Med(8) = A(i+1,j+1);
A(i,j) = median(Med);
end
end
imshow(A);
The output should have been clear , but it appears much more blurred. can you please tell me the problem with the above code.
%start
A = imread('/*path name*/') ;
A = im2double(A);
[m n] = size(A);
Med = [];
%Modified filter
for i=2:m-1
for j=2:n-1
Med(1) = A(i-1,j-1);
Med(2) =A(i-1,j) ;
Med(3) = A(i-1,j+1);
Med(4) = A(i,j-1);
Med(5) = A(i,j+1);
Med(6) = A(i+1, j-1);
Med(7) = A(i+1,j);
Med(8) = A(i+1,j+1);
A(i,j) = median(Med);
end
end
imshow(A);
The output should have been clear , but it appears much more blurred. can you please tell me the problem with the above code.
0