Median filtering is a nonlinear process useful in reducing impulsive, or salt-and-pepper noise. The median filter is also used to preserve edge properties while reducing the noise. Also, the smoothing techniques, like Gaussian blur is also used to reduce noise but it can’t preserve the edge properties. The median filter is widely used in digital image processing just because it preserves edge properties.
- Store the pixel values of input image in an array.
- For each pixel value store all the neighbor pixel value including that cell in a new array (called window).
- Sort the window array.
- Median of window array is used to store output image pixel intensity.
Boundary Issues Example:
2D Median filtering example using a 3 x 3 sampling window:
Extending border values outside with values at the boundary.
Edge preservation :
All smoothing techniques are used to remove noise. The median filter is also one kind of smoothing technique like Gaussian filter, but the only difference between the median filter and Gaussian filter is that the median filter preserve edge property while Gaussian filter does not. Edge preservation is an important property because edges are important for visual appearance. For edge preservation property median filter is widely used in digital image processing.
C++ implementation of median filter algorithm.
- Salt and Pepper Noise removal using C++
- Python | Peak Signal-to-Noise Ratio (PSNR)
- Difference between Low pass filter and High pass filter
- Python | Duplicate substring removal from list
- Python | Substring removal in String list
- Using Counter() in Python to find minimum character removal to make two strings anagram
- filter() in python
- Filter Color with OpenCV
- Gaussian Filter Generation in C++
- Python | Pandas Series.filter()
- Python | Pandas dataframe.filter()
- Python - Filter Non-None dictionary Keys
- Python | Filter even values from a list
- Lambda and filter in Python Examples
- Python PIL | Image filter with ImageFilter module
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.