-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cpp
34 lines (31 loc) · 867 Bytes
/
Source.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
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>
#include <string>
using namespace cv;
using namespace std;
namespace po {
namespace fo {
int x = 5;
}
}
int main() {
string path = "Resources/test.png";
Mat img = imread(path);
Mat imgGray, imgDil, imgErode;
Mat blurredImg;
Mat imgCanny; // -> Used for edge detection
cvtColor(img, imgGray, COLOR_BGR2GRAY);
GaussianBlur(img, blurredImg, Size(3, 3), 3, 0);
// For edge detection, most of the time developers use blur effect.
Canny(blurredImg, imgCanny, 25, 75);
Mat kernel = getStructuringElement(MORPH_RECT, Size(5, 5));
dilate(imgCanny, imgDil, kernel);
imshow("Image", img);
imshow("Grayed Image", imgGray);
imshow("Blurred Image", blurredImg);
imshow("Dilated Image", imgCanny);
imshow("Eroded Image", imgDil);
waitKey(0);
}