Merge pull request #7978 from logic1988:master
authorlogic1988 <1988heqian@163.com>
Mon, 16 Jan 2017 10:19:24 +0000 (18:19 +0800)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Mon, 16 Jan 2017 10:19:24 +0000 (13:19 +0300)
Fix error usage in HitMiss tutorial, and improved the visualization results (#7978)

* Fix error usage in HitMiss tutorial, and improved the visualization results

Fix error usage in HitMiss tutorial, and improved the visualization results

* Update HitMiss.cpp

* Update HitMiss.cpp

samples/cpp/tutorial_code/ImgProc/HitMiss.cpp

index 0463aab..806eec4 100644 (file)
@@ -15,7 +15,7 @@ int main(){
         0, 255, 0, 255, 0, 0, 255, 0,
         0, 255, 255, 255, 0, 0, 0, 0);
 
-    Mat kernel = (Mat_<uchar>(3, 3) <<
+    Mat kernel = (Mat_<int>(3, 3) <<
         0, 1, 0,
         1, -1, 1,
         0, 1, 0);
@@ -23,10 +23,15 @@ int main(){
     Mat output_image;
     morphologyEx(input_image, output_image, MORPH_HITMISS, kernel);
 
-    namedWindow("Original", CV_WINDOW_NORMAL);
+    const int rate = 10;
+    kernel = (kernel + 1) * 127;
+    kernel.convertTo(kernel, CV_8U);
+    cv::resize(kernel, kernel, cv::Size(), rate, rate, INTER_NEAREST);
+    imshow("kernel", kernel);
+    cv::resize(input_image, input_image, cv::Size(), rate, rate, INTER_NEAREST);
     imshow("Original", input_image);
-    namedWindow("Hit or Miss", CV_WINDOW_NORMAL);
+    cv::resize(output_image, output_image, cv::Size(), rate, rate, INTER_NEAREST);
     imshow("Hit or Miss", output_image);
     waitKey(0);
     return 0;
-}
\ No newline at end of file
+}