histogram

- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

Functions
histogram
Complete List of ArrayFire Functions ArrayFire Functions by Category » Image Processing » | Histograms

Histogram of input data. More...

## Functions
AFAPI array | histogram (const array &in, const unsigned nbins, const double minval, const double maxval)
| C++ Interface for histogram. More...
AFAPI array | histogram (const array &in, const unsigned nbins)
| C++ Interface for histogram. More...
AFAPI af_err | af_histogram (af_array *out, const af_array in, const unsigned nbins, const double minval, const double maxval)
| C Interface for histogram. More...

## Detailed Description

Histogram of input data.

A histogram is a representation of the distribution of given data. This representation is essentially a graph consisting of the data range or domain on one axis and frequency of occurence on the other axis. All the data in the domain is counted in the appropriate bin. The total number of elements belonging to each bin is known as the bin's frequency.

The regular histogram function creates bins of equal size between the minimum and maximum of the input data (min and max are calculated internally). The histogram min-max function takes input parameters minimum and maximum, and divides the bins into equal sizes within the range specified by min and max parameters. All values less than min in the data range are placed in the first (min) bin and all values greater than max will be placed in the last (max) bin.

## Function Documentation

AFAPI af_err af_histogram | ( | af_array * | out,
|  | const af_array | in,
|  | const unsigned | nbins,
|  | const double | minval,
|  | const double | maxval
| ) |  |

C Interface for histogram.

Parameters

  [out] | out | (type u32) is the histogram for input array in
  [in] | in | is the input array
  [in] | nbins | Number of bins to populate between min and max
  [in] | minval | minimum bin value (accumulates -inf to min)
  [in] | maxval | minimum bin value (accumulates max to +inf)

Returns
  AF_SUCCESS if the histogram is successfully created, otherwise an appropriate error code is returned.

Examples:
  histogram.cpp.

AFAPI array af::histogram | ( | const array & | in,
|  | const unsigned | nbins,
|  | const double | minval,
|  | const double | maxval
| ) |  |

C++ Interface for histogram.

float input[] = {1, 2, 1, 1, 3, 6, 7, 8, 3};
int nbins = 10;
size_t nElems = sizeof(input)/sizeof(float);
array hist_in(nElems, input);
array hist_out = histogram(hist_in, nbins, 0, 9);
// hist_out = {0, 3, 1, 2, 0, 0, 1, 1, 1, 0}

Parameters

  [in] | in | is the input array
  [in] | nbins | Number of bins to populate between min and max
  [in] | minval | minimum bin value (accumulates -inf to min)
  [in] | maxval | minimum bin value (accumulates max to +inf)

Returns
  histogram array of type u32

Examples:
  binary_thresholding.cpp, edge.cpp, histogram.cpp, and image_demo.cpp.

AFAPI array af::histogram | ( | const array & | in,
|  | const unsigned | nbins
| ) |  |

C++ Interface for histogram.

float input[] = {1, 2, 1, 1, 3, 6, 7, 8, 3};
int nbins = 10;
size_t nElems = sizeof(input)/sizeof(float);
array hist_in(nElems, input);
array hist_out = histogram(hist_in, nbins);
// hist_out = {3, 1, 2, 0, 0, 0, 0, 1, 1, 1}

Parameters

  [in] | in | is the input array
  [in] | nbins | Number of bins to populate between min and max

Returns
  histogram array of type u32