mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
8 years ago
|
#include <opencv2/core.hpp>
|
||
|
#include <opencv2/imgproc.hpp>
|
||
|
#include <opencv2/highgui.hpp>
|
||
|
|
||
|
using namespace cv;
|
||
|
|
||
|
int main(){
|
||
|
Mat input_image = (Mat_<uchar>(8, 8) <<
|
||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
0, 255, 255, 255, 0, 0, 0, 255,
|
||
|
0, 255, 255, 255, 0, 0, 0, 0,
|
||
|
0, 255, 255, 255, 0, 255, 0, 0,
|
||
|
0, 0, 255, 0, 0, 0, 0, 0,
|
||
|
0, 0, 255, 0, 0, 255, 255, 0,
|
||
|
0, 255, 0, 255, 0, 0, 255, 0,
|
||
|
0, 255, 255, 255, 0, 0, 0, 0);
|
||
|
|
||
8 years ago
|
Mat kernel = (Mat_<int>(3, 3) <<
|
||
8 years ago
|
0, 1, 0,
|
||
|
1, -1, 1,
|
||
|
0, 1, 0);
|
||
|
|
||
|
Mat output_image;
|
||
|
morphologyEx(input_image, output_image, MORPH_HITMISS, kernel);
|
||
|
|
||
7 years ago
|
const int rate = 50;
|
||
8 years ago
|
kernel = (kernel + 1) * 127;
|
||
|
kernel.convertTo(kernel, CV_8U);
|
||
7 years ago
|
|
||
8 years ago
|
resize(kernel, kernel, Size(), rate, rate, INTER_NEAREST);
|
||
8 years ago
|
imshow("kernel", kernel);
|
||
7 years ago
|
moveWindow("kernel", 0, 0);
|
||
|
|
||
8 years ago
|
resize(input_image, input_image, Size(), rate, rate, INTER_NEAREST);
|
||
8 years ago
|
imshow("Original", input_image);
|
||
7 years ago
|
moveWindow("Original", 0, 200);
|
||
|
|
||
8 years ago
|
resize(output_image, output_image, Size(), rate, rate, INTER_NEAREST);
|
||
8 years ago
|
imshow("Hit or Miss", output_image);
|
||
7 years ago
|
moveWindow("Hit or Miss", 500, 200);
|
||
|
|
||
8 years ago
|
waitKey(0);
|
||
|
return 0;
|
||
8 years ago
|
}
|