EqualizeHist_Demo.cpp

sample code - Bostjan Vesnicer, 2013-01-10 09:26 am

Download (955 Bytes)

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