MATLAB : Median filter for image restoration.

Srikz

Srikz

@srikz-Z9Z5Su Oct 26, 2024
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.

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform