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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Salt and Pepper Noise removal using C++
- Spatial Filters - Averaging filter and Median filter in Image Processing
- Noise addition using in-built Matlab function
- Python | Peak Signal-to-Noise Ratio (PSNR)
- Python - noise() function in Wand
- Wand noise() function - Python
- Mahotas - Median filter
- Difference between Low pass filter and High pass filter
- Using Counter() in Python to find minimum character removal to make two strings anagram
- How To Make Histogram with Median Line using Altair in Python?
- Create a vignette filter using Python - OpenCV
- How to Filter rows using Pandas Chaining?
- Python | Duplicate substring removal from list
- Python - Summation after elements removal
- Python | Substring removal in String list
- Python | Every Kth element removal in List
- Python - Odd elements removal in List
- Python - Modulo K elements removal
- Python - Consecutive Pairs comma removal
- Python - Custom Rows Removal depending on Kth Column
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.