calcHist
Calculates a histogram of a set of arrays.
计算阵列的直方图。
C++: void calcHist(const Mat*images, int nimages, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform=true, boolaccu-
mulate=false)
C++: void calcHist(const Mat*images, int nimages, const int* channels, InputArray mask, SparseMat&hist, int dims, const int* histSize, const float** ranges, bool uniform=true, boolaccu-
mulate=false)
C: void cvCalcHist(IplImage** image, CvHistogram* hist, int accumulate=0, const CvArr*mask=NULL)
以上是函数原型。
Parameters
images – Source arrays. They all should have the same depth,CV_8U or CV_32F, and the same size. Each of them can have an arbitrary number of channels.
原阵列(因为是指针,可以是一系列图像),应该有相同的深度,8位或32位,但是通道个数可以不同。
nimages– Number of source images.
原图像的个数。
channels – List of the dims channels used to compute the histogram. The first array channels are numerated from 0 to images[0].channels()-1 , the second array channels are counted from images[0].channels() to images[0].channels() + images[1].channels()-1, and so on.
用来计算直方图的通道。
mask– Optional mask. If the matrix is not empty, it must be an 8-bit array of the same
size as images[i]. The non-zero mask elements mark the array elements counted in the
Histogram.
掩膜板,可选的。如果不为空,它必须是与image同大小的8位的阵列。不为零的mask决定哪些元素参与直方图计算。
hist– Output histogram, which is a dense or sparse dims-dimensional array.
输出的直方图。
Dims - Histogram dimensionality that must be positive and not greater than CV_MAX_DIMS(equal to 32 in the current OpenCV version).
直方图的维数。必须为正,并且不能超过CV_MAX_DIMS(现在是32)。
histSize– Array of histogram sizes in each dimension.
直方图的划分个数。一般取16就可以。
ranges– Array of the dims arrays of the histogram bin boundaries in each dimension.
Reference手册上的解释过于繁琐,个人理解就是竖坐标的显示范围。
uniform– Flag indicating whether the histogram is uniform or not (see above).
一般是缺省的。
accumulate– Accumulation flag. If it is set, the histogram is not cleared in the beginning
when it is allocated. This feature enables you to compute a single histogram from several
sets of arrays, or to update the histogram in time.
一般缺省。