-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter2.cpp
More file actions
34 lines (26 loc) · 817 Bytes
/
chapter2.cpp
File metadata and controls
34 lines (26 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <string>
#include <iomanip>
#include <sstream>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv;
using namespace std;
int main() {
Mat image;
Mat imgGray, imgBlurred, imgCanny, imgDilate, imgErode;
image = imread("testImage.jpg");
cvtColor(image, imgGray, COLOR_BGR2GRAY);
GaussianBlur(image, imgBlurred, Size(15,15), 2,2, 4);
Mat kernel = getStructuringElement(MORPH_RECT, Size(3,3));
Canny(imgBlurred,imgCanny, 10, 150, 3, false);
dilate(imgCanny, imgDilate, kernel);
erode(imgDilate, imgErode, kernel);
imshow("Canny", imgCanny);
imshow("DISPLAY", image);
imshow("Dilate", imgDilate);
imshow("Erode", imgErode);
waitKey(0);
return 0;
}