-
Notifications
You must be signed in to change notification settings - Fork 0
/
laplgauss.cpp
51 lines (38 loc) · 1020 Bytes
/
laplgauss.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argvc, char** argv){
VideoCapture video;
float gauss[] = {1,2,1,
2,4,2,
1,2,1};
float laplacian[]={0 ,-1,0,
-1,4 ,-1,
0 ,-1,0};
Mat cap, frame, frame32f, frameF1, frameF2;
Mat mask(3,3,CV_32F);
Mat result;
char key;
video.open(0);
if(!video.isOpened())
return -1;
namedWindow("filtroespacial",1);
for(;;){
video >> cap;
cvtColor(cap, frame, CV_BGR2GRAY);
flip(frame, frame, 1);
imshow("original", frame);
frame.convertTo(frame32f, CV_32F);
//aplicando a mascara de gauss
mask = Mat(3, 3, CV_32F, gauss);
filter2D(frame32f, frameF1, frame32f.depth(), mask, Point(1,1), 0);
//aplicando a mascara laplaciana
mask = Mat(3, 3, CV_32F, laplacian);
filter2D(frameF1, frameF2, frame32f.depth(), mask, Point(1,1), 0);
frameF2.convertTo(result, CV_8U);
imshow("filtroespacial", result);
}
}
return 0;
}