How to do threshold and apply median filter

17 views (last 30 days)
Hi, i am new to Matlab. I am currently doing some image processing, which my camera has 688x520 pixel. The image that i got is a bit noisy which i need to basically set the threshold, and apply the 3x3 median filter.
for example, if i have this 10x5 pixels,
12 12 17 16 17 27 17 12 17 10
13 23 11 12 13 13 13 13 14 15
17 15 16 16 16 19 18 17 18 19
15 17 17 17 19 19 39 19 18 12
16 16 18 18 19 19 19 10 10 16
How do i basically set the threshold, for example the max value should be 20, and if there is any value more than that, the matlab should find it in the array and the 3x3 median filter should be applied. for example in the above case, it should take
12 12 17
13 23 11
17 15 16
and
19 18 17
19 39 19
19 19 10
and from this, the median should be determined, which in the first case is 11, 12, 12, 13, 15, 16, 17, 17 which gives 14 and the second case should be 18
Thanks in advance for the help!

Accepted Answer

Image Analyst
Image Analyst on 15 May 2014
This is what's done in my attached demo. It finds the outliers (in my case values of pure 0 or pure 255) and then replaces only those pixels with the median. You can get a binary image from thresholding like
binaryImage = grayImage > 20;

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!