Function File: medfilt2 (A)
Function File: medfilt2 (A, nhood)
Function File: medfilt2 (A, [M N])
Function File: medfilt2 (…, pad)

Two dimensional median filtering.

Replaces elements of A with the median of their neighbours as defined by the true elements of logical matrix nhood or by a matrix of size M by N. The default nhood is a 3 by 3 matrix of true elements.

## median filtering specifying neighborhood dimensions
medfilt2 (img)         # default is [3 3]
medfilt2 (img, [3 1])  # a 3x1 vector
medfilt2 (img, [5 5])  # 5 element wide square

## median filtering specifying neighborhood
medfilt2 (img, true (5)) # same as [5 5]
nhood = logical ([0 1 0
                  1 1 1
                  0 1 0]);
medfilt2 (img, nhood)    # 3 element wide cross

The optional variable pad defines the padding used in augmenting the borders of A. See padarray for details.

See also: ordfilt2, ordfiltn.

Package: image