Added tutorial sample code: EqualizeHist_Demo.cpp
authorAna Huaman <no@email>
Sun, 3 Jul 2011 18:55:47 +0000 (18:55 +0000)
committerAna Huaman <no@email>
Sun, 3 Jul 2011 18:55:47 +0000 (18:55 +0000)
samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp [new file with mode: 0644]

diff --git a/samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp b/samples/cpp/tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp
new file mode 100644 (file)
index 0000000..dce0138
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+ * @function EqualizeHist_Demo.cpp
+ * @brief Demo code for equalizeHist function
+ * @author OpenCV team
+ */
+
+#include "opencv2/highgui/highgui.hpp"
+#include "opencv2/imgproc/imgproc.hpp"
+#include <iostream>
+#include <stdio.h>
+
+using namespace cv;
+using namespace std;
+
+/**
+ * @function main
+ */
+int main( int argc, char** argv )
+{
+  Mat src, dst;
+
+  char* source_window = "Source image";
+  char* equalized_window = "Equalized Image";
+
+  /// Load image
+  src = imread( argv[1], 1 );
+
+  if( !src.data )
+    { cout<<"Usage: ./Histogram_Demo <path_to_image>"<<endl;
+      return -1; 
+    }
+
+  /// Convert to grayscale
+  cvtColor( src, src, CV_BGR2GRAY );
+
+  /// Apply Histogram Equalization
+  equalizeHist( src, dst );
+  /// Display results
+  namedWindow( source_window, CV_WINDOW_AUTOSIZE );
+  namedWindow( equalized_window, CV_WINDOW_AUTOSIZE );
+
+  imshow( source_window, src );
+  imshow( equalized_window, dst );
+  /// Wait until user exits the program 
+  waitKey(0);
+
+  return 0;
+
+}