-
Notifications
You must be signed in to change notification settings - Fork 0
/
Interface.cpp
67 lines (56 loc) · 1.65 KB
/
Interface.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
#include "Interface.h"
#include "Binarization.h"
using namespace cv;
using namespace std;
void ROI(Mat image)
{
int opction;
cout << "Input data successfully found. Rows:" << image.rows << " cols:" << image.cols << " channels:" << image.channels() << endl;;
cout << endl;
cout << "Please select region of image to binarization:" << endl;
cout << "1.Full image " << endl;
cout << "2.ROI" << endl;
cin >> opction;
switch (opction)
{
case 1:
{
//get full image
x = 0;
y = 0;
ROI_width = image.cols;
ROI_height = image.rows;
break;
}
case 2:
{
cout << "1. Coordinates of the starting point:" << endl;
cout << "X(0-" << image.cols << "):" << " ";
cin >> x;
cout << "Y(0-" << image.rows << "):" << " ";
cin >> y;
cout << endl;
cout << "2. Width of region(0-" << image.cols - x << "):" << " ";
cin >> ROI_width;
cout << endl;
cout << "3. Height of region(0-" << image.rows - y << "):" << " ";
cin >> ROI_height;
break;
}
default:
{
cout << "Wrong values" << endl;
break;
}
}
//showing the selected area (ROI) on the input image
line(image, Point(x,y), Point(x+ROI_width,y), Scalar(0, 0, 255), 5, 8);
line(image, Point(x + ROI_width, y), Point(x + ROI_width, y+ROI_height), Scalar(0, 0, 255), 5, 8);
line(image, Point(x + ROI_width, y + ROI_height), Point(x, y + ROI_height), Scalar(0, 0, 255), 5, 8);
line(image, Point(x, y + ROI_height), Point(x, y), Scalar(0, 0, 255), 5, 8);
namedWindow("ROI", WINDOW_NORMAL);
imshow("ROI", image);
waitKey(0);
cout << "Click space to get histogram of image" << endl;
creatHistogram(image,x,y,ROI_width,ROI_height);
}