M
M
Muhammad2015-02-23 22:44:16
Image processing
Muhammad, 2015-02-23 22:44:16

How does a median filter work?

Good evening. After reading about the median filter on the Internet, I found out that when it is applied, a 3x3 area is taken for each pixel of the image, a color is obtained for each pixel from this area, converted to HSV, brightness is extracted and written to an array. Then the array is sorted and the middle element is extracted. Please tell me what to do next?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Huseynov, 2015-02-23
@muhammad_97

The resulting value is then used as the new brightness value for the given pixel. That's all.
But there are a number of nuances:
0) The median filter can be applied to any channel. But the effect will be different and not always meaningful. In this case, you are describing filtering in the luma channel.
1) Converting to HSV must be done for the entire image before filtering. You can, of course, on the fly, but why complicate it? Want to filter the luma channel? Convert to HSV where the brightness is explicit and filter it. After filtering, you can convert back to RGB if you prefer.
2) Naturally, to calculate a new value, you must use the pixel values ​​from the original image. Therefore, the result should not be written on top, but in a separate memory area.
3) There is a specific edge processing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question