how to do median filter without using medfilt2..

10 次查看(过去 30 天)
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~

采纳的回答

Image Analyst
Image Analyst 2012-4-22
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 个评论
Hasan
Hasan 2013-12-7
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,[]);

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by