In signal processing
, it is often desirable to be able to perform some kind of noise reduction
on an image or signal. The median filter
is a nonlinear digital filtering
technique, often used to remove noise
. Such noise reduction is a typical pre-processing step to improve the results of later processing (for example, edge detection
on an image). Median filtering is very widely used in digital image processing
because, under certain conditions, it preserves edges while removing noise (but see discussion below).
The main idea of the median filter is to run through the signal entry by entry, replacing each entry with the median
of neighboring entries. The pattern of neighbors is called the "window", which slides, entry by entry, over the entire signal. For 1D signals, the most obvious window is just the first few preceding and following entries, whereas for 2D (or higher-dimensional) signals such as images, more complex window patterns are possible (such as "box" or "cross" patterns). Note that if the window has an odd number of entries, then the median
is simple to define: it is just the middle value after all the entries in the window are sorted numerically. For an even number of entries, there is more than one possible median, see median
for more details.
Worked 1D example
To demonstrate, using a window size of three with one entry immediately preceding and following each entry, a median filter will be applied to... Read More