opencv3.0 函数学习 3——equalizeHist 直方图均衡化

equalizeHist 直方图均衡化


函数功能:直方图均衡化,该函数能归一化图像亮度和增强对比度


  1. 为了更好地观察直方图均衡化的效果, 我们使用一张对比度不强的图片作为源图像输入, 如下图:

    ../../../../../_images/Histogram_Equalization_Original_Image.jpg

    它的直方图为:

    ../../../../../_images/Histogram_Equalization_Original_Histogram.jpg

    注意到像素大多集中在直方图中间的强度上.

  2. 使用例程进行均衡化后, 我们得到下面的结果:

    ../../../../../_images/Histogram_Equalization_Equalized_Image.jpg

    这幅图片显然对比度更强. 再验证一下均衡化后图片的直方图:

    ../../../../../_images/Histogram_Equalization_Equalized_Histogram.jpg

    注意到现在像素在整个强度范围内均衡分布.

函数参数


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 = 0j<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 .





你可能感兴趣的:(opencv)