forked from murtazahassan/Learn-OpenCV-cpp-in-4-Hours
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter2.cpp
35 lines (25 loc) · 846 Bytes
/
Chapter2.cpp
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
35
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
/////////////// Basic Functions //////////////////////
void main() {
string path = "Resources/test.png";
Mat img = imread(path);
Mat imgGray, imgBlur, imgCanny, imgDil, imgErode;
cvtColor(img, imgGray, COLOR_BGR2GRAY);
GaussianBlur(imgGray, imgBlur, Size(7, 7), 5, 0);
Canny(imgBlur, imgCanny, 25,75);
Mat kernel = getStructuringElement(MORPH_RECT, Size(3, 3));
dilate(imgCanny, imgDil, kernel);
erode(imgDil, imgErode, kernel);
imshow("Image", img);
imshow("Image Gray", imgGray);
imshow("Image Blur", imgBlur);
imshow("Image Canny", imgCanny);
imshow("Image Dilation", imgDil);
imshow("Image Erode", imgErode);
waitKey(0);
}