히스토그램 평활화
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, const char** argv)
{
//open and read the image
Mat img = imread("C:/Users/Administrator/u1.png", CV_LOAD_IMAGE_COLOR);
if (img.empty())
{
cout << "Image cannot be loaded..!!" << endl;
return -1;
}
//change the color image to grayscale image
cvtColor(img, img, CV_BGR2GRAY);
Mat img_hist_equalized;
//equalize the histogram
equalizeHist(img, img_hist_equalized);
//create windows
namedWindow("Original Image", CV_WINDOW_AUTOSIZE);
namedWindow("Histogram Equalized", CV_WINDOW_AUTOSIZE);
//show the image
imshow("Original Image", img);
imshow("Histogram Equalized", img_hist_equalized);
//wait for key press
waitKey(0);
//destroy all open windows
destroyAllWindows();
return 0;
}