-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
73 lines (59 loc) · 1.63 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
#include "stdio.h"
#include "isothetic.hpp"
int main(int argc, char** argv) {
Mat image, result, final, test, e1, e2;
int size;
int opt;
Scalar color;
int threshval = 200;
char c;
if (argc < 2) {
cout << "Usage: cvsetup <path to image>" << endl;
return 0;
}
image = imread(argv[1]);
if (!image.data) {
printf("No image data \n");
return -1;
}
test = image.clone();
// Convert to greyscale
cvtColor(image, result, CV_RGB2GRAY);
// Binarise the image
cout << "select image type: " << endl;
cout << "[1] white object" << endl << "[2] black object" << endl;
cin >> opt;
if (opt == 1){
threshold(result, result, threshval, 255, CV_THRESH_BINARY_INV);
color = ISO_DARK;
}
else {
threshold(result, result, threshval, 255, CV_THRESH_BINARY);
color = ISO_LIGHT;
}
// Draw the grid
cout << "enter grid size: ";
cin >> size;
final = image.clone();
drawGrid(final, size, color);
// Display the binary image
imshow("Threshold", result);
// Make isothetic cover
vector<Point2i> isotheticcover = animateOIP(result, final, size);
drawOIC(result, isotheticcover, true);
imshow("Isothetic Cover", result);
// Fill the isothetic cover with random colors
int nRows = result.rows;
int nCols = result.cols;
Mat pattern(nRows,nCols, CV_8UC3, Scalar(255,255,255));
patternRandRGB(result, pattern, size, true);
imshow("Random fill", pattern);
effect1(pattern,e1,size);
imshow("Normal Gradient",e1);
effect2(pattern,e2,size);
imshow("Softer Gradient",e2);
rainbowFill(image, test, result, size, true);
imshow("Rainbow", test);
waitKey(0);
return 0;
}