xiconxi

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: $$

分类:

技术点:

相关文章: