DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# GetRank

Value selection function

## SYNOPSIS

`#include "dip_sort.h"`

dip_Error dip_GetRank ( array, datatype, min, max, rank, value )

## FUNCTION

GetRank gets the value at rank `rank` in the array `array`. `min` should be set to the first index of `array`, `max` to the last. `dip_GetRank` will use `array` for temporary storage, so the values in the array will be changed are this function is ready.

## ARGUMENTS

Data type | Name | Description
`dip_float *` | `array` | Array to searched in
`dip_DataType` | `datatype` |
`dip_int` | `min` | minimal array index
`dip_int` | `max` | maximal array index
`dip_int` | `rank` | Rank
`dip_float *` | `value` | Value of the rank element

## EXAMPLE

This example finds the median value for the array.

       dip_float array[ SIZE ], median;
       dip_int rank;

       /* fill the array with values */

       rank = SIZE/2;
       DIPXX( dip_GetRank( array, DIP_DT_FLOAT, 0, (SIZE - 1), rank, &median ));

## SEE ALSO

General information about sorting

`DistributionSort`, `DistributionSortIndices`, `DistributionSortIndices16`, `InsertionSort`, `InsertionSortIndices`, `InsertionSortIndices16`, `QuickSort`, `QuickSortIndices`, `QuickSortIndices16`, `Sort`, `ImageSort`, `SortIndices`, `SortIndices16`, `ImageSortIndices`