How to apply a median filter on a coloured image?

7 views (last 30 days)
Salad Box
Salad Box on 30 Oct 2019
Commented: Walter Roberson on 30 Oct 2019
I'm not exactly sure how 'median filter' works on a coloured image.
I can understand how the median filter work on a black and white image. Because instead of the image being m by n by 3, the image is m by n by 1. So there is only 1 number contained in each pixel. With a 3 by 3 median block, you can easily sort those 9 numbers and take the median number.
However, if it is a colored image, there will be 3 numbers (R, G, B) representing each pixel. In a 3 by 3 block, how to get the median? Do I have to apply the median filter on each channel separately?
Would that also have the risk of generating some artificial pixel values? I mean for instance, the median of R channel is 5, G channel is 20, B channel is 180. Does that mean the median of this block will be [5, 20, 180]. If I'm using [5, 20 180], is it likely that [5, 20, 180] does not belong to any of the 9 pixels in the 3 by 3 block?
  1 Comment
Walter Roberson
Walter Roberson on 30 Oct 2019
You are exactly right, if you process per channel then you do risk creating artificial colors. And that can happen even if you drop into other color spaces such as HSV.
You certainly get into definitional problems of what it means to take a median color.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!