52 lines
1005 B
C++
Raw Normal View History

/**
* @function EqualizeHist_Demo.cpp
* @brief Demo code for equalizeHist function
* @author OpenCV team
*/
2014-07-04 18:48:15 +04:00
#include "opencv2/imgcodecs.hpp"
2016-02-15 15:37:29 +02:00
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
/**
* @function main
*/
int main( int, char** argv )
{
Mat src, dst;
const char* source_window = "Source image";
const char* equalized_window = "Equalized Image";
/// Load image
2016-02-15 15:37:29 +02:00
src = imread( argv[1], IMREAD_COLOR );
if( src.empty() )
2016-02-15 15:37:29 +02:00
{ cout<<"Usage: ./EqualizeHist_Demo <path_to_image>"<<endl;
2012-10-17 03:18:30 +04:00
return -1;
}
/// Convert to grayscale
cvtColor( src, src, COLOR_BGR2GRAY );
/// Apply Histogram Equalization
equalizeHist( src, dst );
2012-10-17 03:18:30 +04:00
/// Display results
namedWindow( source_window, WINDOW_AUTOSIZE );
namedWindow( equalized_window, WINDOW_AUTOSIZE );
imshow( source_window, src );
imshow( equalized_window, dst );
2012-10-17 03:18:30 +04:00
/// Wait until user exits the program
waitKey(0);
return 0;
}