1 /**
2 * @function EqualizeHist_Demo.cpp
3 * @brief Demo code for equalizeHist function
4 * @author OpenCV team
5 */
6
7 #include "opencv2/imgcodecs.hpp"
8 #include "opencv2/highgui/highgui.hpp"
9 #include "opencv2/imgproc/imgproc.hpp"
10 #include <iostream>
11 #include <stdio.h>
12
13 using namespace cv;
14 using namespace std;
15
16 /**
17 * @function main
18 */
main(int,char ** argv)19 int main( int, char** argv )
20 {
21 Mat src, dst;
22
23 const char* source_window = "Source image";
24 const char* equalized_window = "Equalized Image";
25
26 /// Load image
27 src = imread( argv[1], 1 );
28
29 if( src.empty() )
30 { cout<<"Usage: ./Histogram_Demo <path_to_image>"<<endl;
31 return -1;
32 }
33
34 /// Convert to grayscale
35 cvtColor( src, src, COLOR_BGR2GRAY );
36
37 /// Apply Histogram Equalization
38 equalizeHist( src, dst );
39
40 /// Display results
41 namedWindow( source_window, WINDOW_AUTOSIZE );
42 namedWindow( equalized_window, WINDOW_AUTOSIZE );
43
44 imshow( source_window, src );
45 imshow( equalized_window, dst );
46
47 /// Wait until user exits the program
48 waitKey(0);
49
50 return 0;
51
52 }
53