Questions about median, medfilt1, medfilt2

5 views (last 30 days)
AJIT DESHPANDE
AJIT DESHPANDE on 22 Feb 2011
Answered: Amin ur Rehman on 28 Dec 2015
Hello, I am seeing some results of medfilt1 computation by which I am confused. Please see the questions below, and point if I am missing something. 1] b=[ 3 5 -8 6 0]; out=medfilt1(b,3); I expected out to be [3 3 5 0 0] but it is showing out as [4 3 5 0 3] How come? What is wrong here?
2] How does medfilt2 work. Help says "Each output pixel contains the median value in the m-by-n neighborhood around the corresponding pixel in the input image". For m=3,n=3, So does it calculate a 3x3 matrix MAT for each of input pixels placed at its center and do median(median(MAT)) to compute its median value in the m-by-n neighbourhood?
Any pointers will help.
thank you. -AD

Answers (2)

Andrew Newell
Andrew Newell on 22 Feb 2011
Question 1: I get [3 3 5 0 0]. Maybe you have another medfilt1 on your path. What do you get if you type
which medfilt1 -all

Amin ur Rehman
Amin ur Rehman on 28 Dec 2015
>> i=imread('chm.jpg'); imshow(i) noisy_img = imnoise(i,'salt & pepper',0.02); imshow(noisy_img) k = medfilt2(noisy_img); close all; subplot(211);imshow(noisy_img); subplot(212); imshow(k);

Tags

Community Treasure Hunt

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

Start Hunting!