int
im_rank(in, out, xsize, ysize, n)
IMAGE *in, *out;
int xsize, ysize, n;
int im_rank_raw(in, out, xsize, ysize, n)
IMAGE *in, *out;
int xsize, ysize, n;
It works for any non-complex image type, with any number of bands. The input is expanded by copying edge pixels before performing the operation so that the output image has the same size as the input. Edge pixels in the output image are therefore only approximate.
im_rank_raw() works just as im_rank(), but does not expand the input.
im_rank( in, out, m, m, m * m / 2 );
The special cases n == 0 and n == m * m - 1 are useful dilate and expand operators.