A median filter is a non-linear image filter often used to remove impulse noise (i.e., salt and pepper noise). The value of each pixel in the resulting image is equal to the median of the intensity values from the original image in a given neighborhood. If the neighborhood mask has an odd number of entries, the median is the middle element of all numerically sorted entries. For an even number of entries, the median is calculated as the mean of the two entries in the middle. Users need to input the kernel size and the type of neighborhood mask, which can be a cross (4-connected) or box (8-connected) pattern.
The threshold value can be specified by users as an expression combining mathematical functions and operators with variables based on the current raw or filtered image. Variables provided by this filter are:
| Med.I | current raw input image |
| Med.F | corresponding filtered image |