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

◆ af_histogram()

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]inis the input array
[in]nbinsNumber of bins to populate between min and max
[in]minvalminimum bin value (accumulates -inf to min)
[in]maxvalminimum bin value (accumulates max to +inf)
Returns
AF_SUCCESS if the histogram is successfully created, otherwise an appropriate error code is returned.

◆ histogram() [1/2]

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]inis the input array
[in]nbinsNumber of bins to populate between min and max
Returns
histogram array of type u32

◆ histogram() [2/2]

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]inis the input array
[in]nbinsNumber of bins to populate between min and max
[in]minvalminimum bin value (accumulates -inf to min)
[in]maxvalminimum bin value (accumulates max to +inf)
Returns
histogram array of type u32
Examples
graphics/histogram.cpp, image_processing/binary_thresholding.cpp, image_processing/edge.cpp, image_processing/image_demo.cpp, and pde/swe.cpp.
afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:327
af::histogram
AFAPI array histogram(const array &in, const unsigned nbins, const double minval, const double maxval)
C++ Interface for histogram.