-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path33_Tophat&Gradient.cpp
35 lines (26 loc) · 1.04 KB
/
33_Tophat&Gradient.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<iostream>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
// Tophat -> yuvarlak kenar islemlerinde
// Gradient -> nesnenin ana hatlarinii belirtir ( Canny kenar tespiti ile karistirilmamali )
int main()
{
Mat gradimg, topimg, tophat, gradient;
gradimg = imread("gradient.jpg");
imshow("gradient original", gradimg);
topimg = imread("tophat.jpg");
imshow("tophat original", topimg);
Mat element = getStructuringElement(MORPH_RECT, Size(3, 3)); // Size filtre boyutu arttirlarak daha olcekli arama yapilabilir
// Tophat Morphology
morphologyEx(topimg, tophat, MORPH_TOPHAT, element, Point(-1, -1), 5); // topimg de tophat morfolojisini 5 kez islemle( MORPH_TOPHAT ile)
// son arguman olan islemleme miktari arttirilarak daha saglikli tarama yapilabilir.
imshow("tophat", tophat);
// Gradient Morphology
morphologyEx(gradimg, gradient, MORPH_GRADIENT, element, Point(-1, -1), 3);
imshow("gradient", gradient);
waitKey(0);
return 0;
}