直方图均衡算法(Histogram Equalized)

时间:2019-10-31
本文章向大家介绍直方图均衡算法(Histogram Equalized),主要包括直方图均衡算法(Histogram Equalized)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Lab1: Histogram Equalization

1. 实验环境(C++)

  • 操作系统版本 MacOS Catalina 10.15
  • OpenCV4.0 (imgcodecs | core | highgui | imgproc)
  • Cmake-3.14
  • Clang-1100.0.33.8

2. 实验步骤

  1. Calculate the histogram H for src

  2. Normalize the histogram.

     std::array<double, 256> calNormalizedHist(cv::Mat& source) {
         std::array<double, 256> acc{0};
         // Calculate the histogram H for src
         for(int i = 0; i < source.rows; i++)
             for (int j = 0; j < source.cols; j++)
                 acc[ source.ptr<uchar>(i)[j]] ++;
         // Normalize the histogram.
         for(int i = 0; i < acc.size(); i++)
             acc[i] /= source.rows * source.cols;
         return acc;
     }
  3. Compute the integral of the histogram: H'

  4. Transform the image using H′ as a look-up table: \[

    原文地址:https://www.cnblogs.com/xiconxi/p/11770899.html