-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanny.cpp
More file actions
55 lines (41 loc) · 1.3 KB
/
canny.cpp
File metadata and controls
55 lines (41 loc) · 1.3 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include "include/canny.h"
using namespace cv;
using namespace std;
canny::canny (int lowThreshold, int max_lowThreshold, int ratio) {
int kernel_size{1};
Mat src;
Mat src_gray;
Mat dst;
Mat detected_edges;
}
Mat canny::CannyThreshold(int, void*)
{
cerr << "Enters CannyThreshhold" << endl;
// Blur the image with a filter of kernel size 3
blur(src_gray, detected_edges, Size(3,3));
// kernel_size -> Size of the Sobel Kernel
Canny(detected_edges, detected_edges, lowThreshold, lowThreshold*ratio);
// Create a Matrix with all zeros (black)
dst = Scalar::all(0);
// areas identified as edges copied to a black background
src.copyTo(dst, detected_edges);
return dst;
}
Mat canny::prepare_canny(string file){
cerr << "Calls calc_canny()" << endl;
// Open image
src = imread(file , IMREAD_COLOR); // Load an image
if(src.empty()){
cout << "Could not open or find the image!\n" << endl;
}
// Create matrix with the same size as the image
dst.create(src.size(), src.type());
// Grayscale
cvtColor(src, src_gray, COLOR_BGR2GRAY);
Mat dst = CannyThreshold(0, 0);
return dst;
}