### Method

# Vips Image rank

#### Declaration [src]

    int
    vips_rank (
      VipsImage* in,
      VipsImage** out,
      int width,
      int height,
      int index,
      ...
    )

#### Description [src]

`vips_rank()` does rank filtering on an image. A window of size `width` by `height` is passed over the image. At each position, the pixels inside the window are sorted into ascending order and the pixel at position `index` is output. `index` numbers from 0.

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.

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

    vips_rank(in, out, m, m, m * m / 2);

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

See also

`vips_conv()`, `vips_median()`, `vips_spcor()`.

This method is not directly available to language bindings.

#### Parameters

`out`

  Type: `VipsImage`

  Output image.

  The argument will be set by the function.
  The caller of the method takes ownership of the returned data, and is responsible for freeing it.

`width`

  Type: `int`

  Width of region.

`height`

  Type: `int`

  Height of region.

`index`

  Type: `int`

  Select pixel.

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on error.