af_histogram

The C interface for histogram. More...

afError af_histogram_S (float *d_hist, unsigned length, const float *d_data, unsigned nbins, const float *h_bins, unsigned nsets, unsigned ngfor)
 Form a non-normalized histogram from input matrix. More...
 
afError af_histminmax_S (float *d_hist, unsigned len, const float *d_data, unsigned bins, const float *h_data, unsigned nsets, unsigned ngfor, float min, float max)
 Form a non-normalized histogram from input matrix, using the specified minimum and maximum range for binning. More...
 

Detailed Description

The C interface for histogram.

A histogram is a representation of the distribution of data in an image. 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 (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.

// Create a histogram using 256 bins
array hist_out = histogram(hist_in, 256);
// Histogram with explicit min/max
// generate sample input data
// generates an array with 50 elements from -25 to 24.
array hist_in = seq(-25, 24)
// Create histogram using 10 bins,with bins scaled from 1 to 10
// bin[0] gets -inf to 1
// bin[9] gets 10 to inf
array hist_out = histogram(img_in, 10, 0, 10);
// hist_out will be [26, 1, 1, 1, 1, 1, 1, 1, 1, 16]

Data normalization via histogram equalization

// img_in and img_out are single channel images
array ihist = histogram(img_in, 256);
array img_out = histequal(img_in, ihist);

Function Documentation

afError af_histogram_S ( float *  d_hist,
unsigned  length,
const float *  d_data,
unsigned  nbins,
const float *  h_bins,
unsigned  nsets,
unsigned  ngfor 
)

Form a non-normalized histogram from input matrix.

Parameters
[out]d_histCount of occurrences - PxN matrix
[in]lengthLength of input matrix d_data - N
[in]d_dataDevice-side vector or matrix - MxN
[in]nbinsNumber of bins in h_bins - P
[in]h_binsHost-side vector indicating center of each bin (can be NULL)
[in]nsetsNumber of rows in input data - M
[in]ngforNumber of gfor passes
Note
d_hist is: a 1xP vector hist for vector inputs, or a PxN matrix hist for MxN matrix inputsSingle-precision histogram calculation
afError af_histminmax_S ( float *  d_hist,
unsigned  len,
const float *  d_data,
unsigned  bins,
const float *  h_data,
unsigned  nsets,
unsigned  ngfor,
float  min,
float  max 
)

Form a non-normalized histogram from input matrix, using the specified minimum and maximum range for binning.

Parameters
[out]d_histCount of occurrences - PxN matrix
[in]lenLength of input matrix d_data - N
[in]d_dataDevice-side vector or matrix - MxN
[in]binsNumber of bins in h_bins - P
[in]h_dataHost-side vector indicating center of each bin (can be NULL)
[in]nsetsNumber of rows in input data - M
[in]ngforNumber of gfor passes
[in]minMinimum binned value (eg. 0)
[in]maxMaximum binned value (eg. 255)
Note
d_hist is: a 1xP vector hist for vector inputs, or a PxN matrix hist for MxN matrix inputsSingle-precision histogram calculation