forked from arcreane/gimpsep-photowish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdilation_erosion.cpp
131 lines (93 loc) · 2.41 KB
/
dilation_erosion.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <iostream>
#include "Menu.h"
#include "Header.h"
#include <opencv2/opencv.hpp>
#include "opencv2/core/utils/logger.hpp"
using namespace std;
using namespace cv;
int dilation_erosion() {
//test image path: C:/Users/arthu/Desktop/Ecole/AppMultimedia/C++/crocodile.png
Mat imageOrigin;
string imagePath;
string white = getColor("white");
string blue = getColor("blue");
string red = getColor("red");
string Set[] = { blue, white, white };
int counter = 0;
char key;
while (imageOrigin.empty()) {
gotoxy(0, 3);
cout << white << "Enter the absolute path of your image : ";
cin >> imagePath;
try
{
imageOrigin = imread(imagePath);
}
catch (const std::exception& e)
{
cerr << e.what();
}
}
//imshow("source image", imageOrigin);
//waitKey(0);
for (int i = 0; ; ) {
gotoxy(0, 5);
cout << white << "What would you like to do ?\n";
gotoxy(0, 6);
cout << Set[0] << "1. Dilation";
gotoxy(0, 7);
cout << Set[1] << "2. Erosion";
gotoxy(0, 8);
cout << Set[2] << "3. Return";
key = _getch();
if (key == 72 && counter > 0) {
counter--;
}
if (key == 80 && counter < 2) {
counter++;
}
if (key == '\r') {
gotoxy(0, 17);
cout << " ";
switch (counter)
{
case 0: //dilate image
gotoxy(0, 10);
cout << white << "\Dilation :\n";
dilation(imageOrigin);
break;
case 1: //erode image
gotoxy(0, 10);
cout << white << "\Erosion :\n";
erosion(imageOrigin);
break;
case 2:
system("CLS");
return 0;
break;
default:
break;
}
}
Set[0] = white;
Set[1] = white;
Set[2] = white;
switch (counter)
{
case 0:
Set[0] = blue;
break;
case 1:
Set[1] = blue;
break;
case 2:
Set[2] = red;
break;
default:
break;
}
}
system("pause");
cout << "Finished";
return 0;
}