-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
94 lines (65 loc) · 2.03 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
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include "similarity_graph.h"
#include "voronoi_diagram.h"
#include "spline.h"
#include "optimize.h"
using namespace cv;
int main(int argc, char* argv[])
{
Mat image;
if (argc == 1)
{
image = imread("pixelart.png");
}
else if (argc == 2)
{
image = imread(argv[1]);
}
else { printf("Please give only the path to one pixelart \n"); return -1; }
if ( !image.data )
{
printf("No image data \n");
return -1;
}
imshow("Pixel art", image);
int nbr_lignes = image.rows;
int nbr_colonnes = image.cols;
std::cout<<"lignes : "<<nbr_lignes<<" colonnes : "<<nbr_colonnes<<std::endl;
waitKey(0);
similarity_graph graphe(image);
imshow("YUV", graphe.image_YUV);
waitKey(0);
graphe.init_graph();
graphe.compare_YUV();
imshow("nodes avant resolution", graphe.draw_nodes(21));
waitKey(0);
graphe.resolu();
imshow("nodes apres resolution", graphe.draw_nodes(21));
waitKey(0);
voronoi voro = voronoi(image ,graphe.pixels_nodes, 20.0f);
voro.init_cells();
Mat img_voro = voro.draw_voronoi();
imshow("voronoi pixel", img_voro);
waitKey(0);
voro.compute_vertex();
img_voro = voro.draw_voronoi();
imshow("voronoi cellules", img_voro);
waitKey(0);
voro.draw_cells(img_voro);
imshow("voronoi contours cellules", img_voro);
waitKey(0);
voro.polygon();
voro.union_poly();
Mat img_voro_union = voro.draw_cells_union();
imshow("voronoi union cellules", img_voro_union);
waitKey(0);
B_splines bsplines = B_splines(voro);
bsplines.find_holes_splines();
optimize_Bsplines(bsplines);
Mat drawed_splines = Mat(voro.rows*ceil(voro.scale),voro.cols*ceil(voro.scale),CV_8UC3,Scalar(255,255,255));
Mat drawed_spline = bsplines.color_spline(drawed_splines);
imshow("spline", drawed_spline);
waitKey(0);
return 0;
}