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++
- Difference between Low pass filter and High pass filter
- Python | Duplicate substring removal from list
- Using Counter() in Python to find minimum character removal to make two strings anagram
- filter() in python
- Gaussian Filter Generation in C++
- Filter Color with OpenCV
- Python | Pandas dataframe.filter()
- Lambda and filter in Python Examples
- Python | Pandas Series.filter()
- Python | Filter even values from a list
- Python | Unique dictionary filter in list
- Python PIL | Image filter with ImageFilter module
- Python | Filter dictionary of tuples by condition
- Python | Filter the negative values from given dictionary
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.