一下附上该函数的声明:
void calcHist(const Mat* arrays, int narrays, const int* channels, InputArray mask, OutputArray
hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=
false );
void calcHist(const Mat* arrays, int narrays, const int* channels, InputArray mask, SparseMat&
hist, int dims, const int* histSize, const float** ranges, bool uniform=true, bool accumulate=
false );
其实,该参数的理解难度并不是很大,主要是有那么一点点绕,只是因为我(笨得很)用了很久之后才发现原来是这样,所以在此记录一下。
直方图统计都是针对单通道图片的,所以如果出现多通道的图片,那就对其单个通道分别依次统计,如果是多幅图片,那就把所有图片的所有通道按顺序编号(从0开始),然后channels就存储相应的通道序号就可以指定计算范围了。
如果有四张图片:img1,img2,img3,img4,通道数分别是3,1,2,2,所以一字排开总共会有8张单通道图片,按存储先后顺序编号为0~7.
所以channels[]取相应数字的集合就OK了。