필터 지우기
필터 지우기

Manual median filter design

조회 수: 2 (최근 30일)
Stefan
Stefan 2013년 12월 2일
댓글: Image Analyst 2013년 12월 2일
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.

채택된 답변

Anand
Anand 2013년 12월 2일
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.
  댓글 수: 1
Image Analyst
Image Analyst 2013년 12월 2일
Right, good point - I keep forgetting that blockproc() is in that toolbox. It seems so general that I always think it's in base MATLAB, but it's not.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 12월 2일
See my blockproc() demos (attached below in blue). Demo1 does the median. Demo2 does a custom filter, like you'd do with nlfilter(). Note: blockproc() normally moves in "jumps" of the window size. To get it to move over just one pixel instead of the whole window width, you'll need to adjust the 'Bordersize' option of blockproc().

Community Treasure Hunt

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

Start Hunting!

Translated by