equalizeHist 直方图均衡化
函数功能:直方图均衡化,该函数能归一化图像亮度和增强对比度
-
为了更好地观察直方图均衡化的效果, 我们使用一张对比度不强的图片作为源图像输入, 如下图:
它的直方图为:
注意到像素大多集中在直方图中间的强度上.
-
使用例程进行均衡化后, 我们得到下面的结果:
这幅图片显然对比度更强. 再验证一下均衡化后图片的直方图:
注意到现在像素在整个强度范围内均衡分布.
函数参数
void cv::equalizeHist | ( | InputArray | src, |
OutputArray | dst | ||
) |
Equalizes the histogram of a grayscale image.
The function equalizes the histogram of the input image using the following algorithm:
- Calculate the histogram H for src .
- Normalize the histogram so that the sum of histogram bins is 255.
- Compute the integral of the histogram:H ′ i =∑ 0≤j<i H(j)
- Transform the image using H ′ as a look-up table: dst(x,y)=H ′ (src(x,y))
The algorithm normalizes the brightness and increases the contrast of the image.
- Parameters
-
src Source 8-bit single channel image. 注:需要原图需要灰度图 dst Destination image of the same size and type as src .