Name

MedianFilter — applies a median filter to an image

Calling Sequence

FilteredImage = MedianFilter(OriginalImage, FilterSize);

Parameters

OriginalImage

2D matrix of type boolean, uint8, uint16, uint32 or double

FilterSize

vector of type double with two components, the first one specifies the height, the second one the width of the filter

FilteredImage

2D matrix of the same size and type as OriginalImage

Description

This function applies a median filter to an image.

Examples

OriginalImage = zeros(9, 9);      // Image is generated

OriginalImage(4 : 6, 4 : 6) = 1;  // block of object pixels is generated

OriginalImage(5, 2) = 1;          // single object pixel is set, will disappear after filtering

FilterSize = [3 3];               // filter has three rows and three columns

FilteredImage = MedianFilter(OriginalImage, FilterSize)