直方图(Histogram)均衡化:是一种体改图像对比度的方法,拉伸图像灰度值范围。
/*
The algorithm normalizes the brightness and increases the contrast of the image.
@param src Source 8-bit single channel image.
@param dst Destination image of the same size and type as src .
*/
CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );
src必须是8位的单通道图像。
直方图均衡化思想:把原始图像的直方图变为均匀分布的的形式,这样就增加了像素灰度值的动态范围,从而达到了增强图像的整体对比度的效果。
直方图本身:
直方图是对一幅图像中出现的所有像素值的频次统计。将统计结果话在坐标系中,x横坐标代表像素值,y纵坐标代表的是对应像素值出现的次数。
除了对图像像素值的直方图,还有图像梯度、每个像素的角度、等一切图像的属性值,我们都可以建立直方图。但是,图像像素的直方图是最常见的。
直方图有几个属性:
dims:表示维度,对灰度图像来说只有一个通道,则dims=1;
bins:表示在维度中子区域大小划分,bins=256,划分为256个级别;
range:表示值的范围,灰度值范围为[0~255]之间。
相关API:
/*
@param images Source arrays. They all should have the same depth, CV_8U, CV_16U or CV_32F , and the same
size. Each of them can have an arbitrary number of channels.
@param nimages Number of source images.
@param 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.
@param 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.
@