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.

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.

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).

histSize – Array of histogram sizes in each dimension.

ranges – Array of the dims arrays of the histogram bin boundaries in each dimension. When the histogram is uniform ( uniform =true), then for each dimension i it is enough to specify the lower (inclusive) boundary of the 0-th histogram bin and the upper (exclusive) boundary for the last histogram bin histSize[i]-1 . That is, in case of a uniform histogram each of ranges[i] is an array of 2 elements. When the histogram is not uniform ( uniform=false ), then each of ranges[i] contains histSize[i]+1 elements: . The array elements, that are not between and , are not counted in the histogram.

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.

dtype – when negative, the output array has the same type as src; otherwise, it has the same number of channels as src and the depth =CV_MAT_DEPTH(dtype).

mask – optional operation mask.

The functions normalize scale and shift the input array elements so that

(where p=Inf, 1 or 2) when normType=NORM_INF, NORM_L1, or NORM_L2, respectively; or so that

when normType=NORM_MINMAX (for dense arrays only).
The optional mask specifies a sub-array to be normalized. This means that the norm or min-n-max are calculated over the sub-array, and then this sub-array is modified to be normalized.

Result:

8 comments:

Very useful post! nevertheless, you need to set your range like this float range[] = { 0, 256 }; in order to ge all the bins. I tested counting the pixels you get in the histogram, and I got the right value when I set range like this.