16.16 Median FilterMath-MedianFilter
Description
The medianflt2 X-Function filter examines the N by N pixels centered on each cell of a matrix, finds the median value of the N by N cells, and then replaces the central cell value with the median value. The filter is useful for removing spot noise (white spots, black spots) from an image because noisy pixels typically have values that depart significantly from the median cell values.
To use this function:
- Create a new matrix with data.
- Activate the matrix.
- Select Analysis: Mathematics: Median Filter. This opens the medianflt2 dialog.
Dialog Options
Recalculate
|
Controls recalculation of analysis results
For more information, see: Recalculating Analysis Results
|
Input Matrix
|
The input Matrix.
For help with range controls, see: Specifying Your Input Data
|
Output Matrix
|
The output matrix.
For help with the range controls, see: Output Results
|
Window size
|
Specify the filter window size.
|
Padding Option
|
Specifies how to pad cells outside borders.
- ZeroPadding
- Pads with zeros.
- MapPadding
- Uses reflection padding.
- RepeatPadding
- Repeats edge values.
|
Algorithm
This function examines an matrix centered on each cell of a matrix, finds the median value of the N by N cells, and then replaces the central cell value with the median value.
For example:
Source matrix:
For a 3 X 3 filter matrix, centered on cell (2,2), the matrix is:
The median value of the filter matrix is ; therefore cell(2,2) in the output matrix remains .
When applying filtering to the edge of source matrix, the filter may fall outside the matrix. In such cases, we can pad the area outside the source matrix with zeros (Zero Padding), by reflection padding (Map Padding), or by repeating edge values (Repeat Padding).
|