## Documentation Center |

2-D order-statistic filtering

`B = ordfilt2(A, order, domain)B = ordfilt2(A, order, domain, S)B = ordfilt2(..., padopt)`

`B = ordfilt2(A, order, domain)` replaces
each element in `A` by the `order`th
element in the sorted set of neighbors specified by the nonzero elements
in `domain`.

`B = ordfilt2(A, order, domain, S)` where `S` is
the same size as `domain`, uses the values of `S` corresponding
to the nonzero values of `domain` as additive offsets.

`B = ordfilt2(..., padopt)` controls
how the matrix boundaries are padded. Set `padopt` to `'zeros'` (the
default) or `'symmetric'`. If `padopt` is `'zeros'`, `A` is
padded with 0's at the boundaries. If `padopt` is `'symmetric'`, `A` is
symmetrically extended at the boundaries.

The class of `A` can be `logical`, `uint8`, `uint16`,
or `double`. The class of `B` is
the same as the class of `A`, unless the additive
offset form of `ordfilt2` is used, in which case
the class of `B` is `double`.

This examples uses a maximum filter with a `[5 5]` neighborhood.
This is equivalent to `imdilate(image,strel('square',5))`.

A = imread('snowflakes.png'); B = ordfilt2(A,25,true(5)); figure, imshow(A), figure, imshow(B)

[1] Haralick, Robert M., and Linda G. Shapiro, *Computer
and Robot Vision, *Volume I, Addison-Wesley, 1992.

[2] Huang, T.S., G.J.Yang, and G.Y.Tang. "A fast two-dimensional median filtering algorithm.", IEEE transactions on Acoustics, Speech and Signal Processing, Vol ASSP 27, No. 1, February 1979

Was this topic helpful?