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.

Replies

You are reading an archived discussion.

Related Posts

hi..... frndz plz tel me......low frequencies r more effected by scattering or high frequencies?????
This video lecture series on Structural Analysis by Prof. P. Banerjee Dept. of Civil Engineering IIT Bombay. [video=youtube;qhEton-EEOw]https://www.youtube.com/watch?v=qhEton-EEOw[/video]
Engineering vs. Liberal Arts: Who’s Right—Bill or Steve? Saw this provocative article. Waving a red flag before CEans? Engineering vs. Liberal Arts: Who
People with diabetes, who currently monitor their glucose with painful and inconvenient blood tests or implanted probes, could in the future get the same results quickly and non-invasively by safely...
Nasa awards contract to Cessna for airliner 'magic skin' https://www.wired.co.uk/news/archive/2011-04/8/magic-skin-for-aircraft