-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
118 lines (115 loc) · 3.75 KB
/
main.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
#include <iostream> // std::cout
#include <fstream> // std::ifstream
#include <cstdint>
#include "Image.h"
using namespace std;
int main(int argc, char *argv[])
{
bool run = true;
int selection, treshold;
string bin1Name = "image1.bin", bin2Name = "image2.bin", outputName = "output.txt";
ifstream bin1, bin2;
ofstream output;
if(argc < 3)
{
cout << "correct arguments not supplied, using default settings";
}
else
{
bin1Name = argv[1];
bin2Name = argv[2];
outputName = argv[3];
}
bin1.open(bin1Name, std::ifstream::binary);
bin2.open(bin2Name, std::ifstream::binary);
output.open(outputName, ios::app);
Image image1, image2;
bin1 >> image1;
bin2 >> image2;
cout << "\nEnter treshold for pixel-binary conversion:\n -> ";
cin >> treshold;
image1.setTreshold(treshold);
image2.setTreshold(treshold);
while (run)
{
cout << "\nSelect your operation:\n\n\t[1] -> Print image\n\t[2] -> Apply operation on images\n\t[3] -> Exit\n -> ";
cin >> selection;
switch (selection)
{
case 1:
cout << "\nSelect image:\n\n\t[1] -> " << bin1Name << "\n\t[2] -> " << bin2Name << "\n- > ";
Image image;
cin >> selection;
if (selection == 1)
{
image.copy(image1);
output << "\nImage 1 ";
}
else if (selection == 2){
image.copy(image2);
output << "\nImage 2 ";
}
cout << "\nApply sobel filter?\n\t[1] -> Yes\n\t[2] -> No\n -> ";
cin >> selection;
if (selection == 1)
{
image.sobel();
image.print();
output << "with sobel filter:\n";
output << image;
}
else{
image.print();
output << "without sobel filter:\n";
output << image;
}
break;
case 2:
cout << "\n\tSelect your operation:\n\n\t\t[1] -> " << bin1Name << " + " << bin2Name << " (Logical OR)" << endl;
cout << "\t\t[2] -> " << bin1Name << " * " << bin2Name << " (Logical AND)" << endl;
cout << "\t\t[3] -> !" << bin1Name << " or !" << bin2Name << " (Logical NOT)\n\t -> ";
cin >> selection;
if (selection == 1)
{
Image result = image1 + image2;
result.setTreshold(treshold);
result.print();
output << "\nImage 1 + Image 2 (Logical OR):\n";
output << result;
}
else if (selection == 2)
{
Image result = image1 * image2;
result.setTreshold(treshold);
result.print();
output << "\nImage 1 * Image 2 (Logical AND):\n";
output << result;
}
else if (selection == 3)
{
cout << "\n\t\t\t[1] -> !" << bin1Name;
cout << "\n\t\t\t[2] -> !" << bin2Name;
cout << "\n\t\t -> ";
cin >> selection;
if (selection == 1)
{
Image result = !image1;
result.print();
output << "\n!Image 1 (Logical NOT):\n";
output << result;
}
else if (selection == 2)
{
Image result = !image2;
result.print();
output << "\n!Image 2 (Logical NOT):\n";
output << result;
}
}
break;
case 3:
run = false;
}
}
return 0;
}