MATLAB: Manual median filter design

filterimage processingImage Processing Toolbox

Hello, I want to implement a simple median filter of window size '5' manually.I found a thread here
medain with blockpro(),nlfilter but when I tried with the help blockpro() and nlfilter() both showed nlfilter() and blockpro() not found. I don't have imageprocessing toolbox.
So,can anyone help me out in implementing the median filter manually.

Best Answer

Well if you don't have the Image Processing Toolbox, I'm afraid you won't be able to use blockproc. In that case, you would have to resort to something like this:
imout = zeros(size(im),class(im));
for m = 3 : size(im,1)-2
for n = 3 : size(im,2)-2
list = im(m-2:m+2,n-2:n+2);
imout(m,n) = median(list(:));
end
end
Note that this is the most naive way to do it. There are lots of better ways to do it, but this is the easiest to understand.
Related Question