Table of Contents

## Name

im_rank, im_rank_raw - rank filter

## Synopsis

#include <vips/vips.h>

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;

## Description

im_rank() does rank filtering on an image. A window of size xsize by ysize is passed over the image. At each position, the pixels inside the window are sorted into ascending order and the pixel at the nth position is output. n numbers from 1.

It works for any non-complex image type, with any number of bands. A black border is added to the output image to make it the same size as the input.

im_rank_raw() works just as im_rank(), but does not add the border.

## Examples

For a median filter with mask size m (3 for 3x3, 5 for 5x5, etc.) use

im_rank( in, out, m, m, (m*m + 1)/2 );

The special cases n == 1 and n == m*m are useful dilate and expand operators.

## Return Value

The function returns 0 on success and -1 on error.

## See Also

im_conv(3X) , im_fastcor(3X) .

## Copyright

1989-1996 The National Gallery and Birkbeck College

Table of Contents

- Name
- Synopsis
- Description
- Examples
- Return Value
- See Also
- Copyright