Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

how to do median filter without using medfilt2..

Asked by ganesh on 22 Apr 2012
Latest activity Commented on by Hasan on 7 Dec 2013

hello, i need to do an image enhancement using median filter... but im not suppose to use medfilt2 or those function in matlab... how create my own function... im not sure on how to do it... can some1 help me in this..?? ~THANK YOU~

0 Comments

ganesh

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst on 22 Apr 2012
Accepted answer

Use blockproc() or nlfilter() and inside the function call the sort() routine and take the middle value. If you can't even use those functions, then you'll have to do the whole thing yourself with a bunch of nested for loops.

2 Comments

ganesh on 22 Apr 2012

owh... ok ok... thx alot....

Hasan on 7 Dec 2013

I=imread('super.jpeg');

I_G=double(rgb2gray(I));

IG_N=imnoise(I_G,'salt & pepper');

[r,c]=size(IG_N);

F_SP=zeros(r,c);

for i=2:r-1

    for j=2:c-1
        flt=[IG_N(i-1,j-1),IG_N(i-1,j),IG_N(i-1,j+1),IG_N(i,j-
1),IG_N(i,j),IG_N(i,j+1),IG_N(i+1,j-1),IG_N(i+1,j),IG_N(i+1,j+1)];
F_SP(i,j)=median(flt);
    end
end
figure;imshow(IG_N,[]);
figure;imshow(F_SP,[]);
Image Analyst

Contact us