CUDA
C/C++    Fortran   

Histograms

Functions

array histogram (const array &data, unsigned nbins)
 Histogram of all values in data.
array histogram (const array &data, unsigned nbins, float min, float max)
 Histogram of all values in data.
array histequal (const array &data, const array &histogram)
 Data normalization via histogram equalization.

Function Documentation

array af::histogram ( const array &  data,
unsigned  nbins 
)

Histogram of all values in data.

       // create image histogram using 256 bins
       array ihist = histogram(img_in, 256);
Parameters:
[in]dataimage treated as vector
[in]nbinsNumber of output bins to populate
Returns:
non-normalized histogram of data (1D)
Examples:
examples/image_processing/image_demo.cpp, and examples/machine_learning/kmeans.cpp.
array af::histogram ( const array &  data,
unsigned  nbins,
float  min,
float  max 
)

Histogram of all values in data.

       // create image histogram using 100 bins,
       //  with bins scaled from 1 to 10, and
       //   bin[0]  gets -inf to 1
       //   bin[99] gets   10 to inf
       array ihist = histogram(img_in, 100, 0, 10);
Parameters:
[in]dataimage treated as vector
[in]nbinsNumber of bins to populate between min and max
[in]minminimum bin value (accumulates -inf to min)
[in]maxmaximum bin value (accumulates max to inf)
Returns:
non-normalized histogram of data (1D)
array af::histequal ( const array &  data,
const array &  histogram 
)

Data normalization via histogram equalization.

       // img_in and img_out are single channel images
       // image histogram equalization
       array ihist = histogram(img_in, 256);
       array img_out = histequal(img_in, ihist);
Parameters:
[in]datanon-normalized input (!! assumes values [0-255] !!)
[in]histogramtarget histogram to approximate in output (based on # of bins)
Returns:
data with histogram approximately equal to histogram
Note:
image must be grayscale (single channel)
Examples:
examples/image_processing/image_demo.cpp.