-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
99 lines (79 loc) · 2.69 KB
/
main.cpp
File metadata and controls
99 lines (79 loc) · 2.69 KB
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
// File: main.cpp
// Author: cheeren, zhangwil
// Date: 2023-03-23
// Description: Partial test of PA3 functionality
// Reads Point data from external files
// Produces PNG images of the point sets
#include "compression/PNG.h"
#include "compression/RGBAPixel.h"
#include "qtcount.h"
#include "qtvar.h"
using namespace compression;
using namespace std;
int main() {
// read in image
PNG origIm1;
origIm1.readFromFile("images/orig/flower.png");
PNG origIm2;
origIm2.readFromFile("images/orig/garden.png");
PNG origIm3;
origIm3.readFromFile("images/orig/sky.png");
PNG origIm4;
origIm4.readFromFile("images/orig/snowMountain.png");
PNG origIm5;
origIm5.readFromFile("images/orig/vancouverDowntown.png");
// use it to build a quadtree
qtcount t1(origIm1);
qtcount tCopy1(t1);
qtcount t2(origIm2);
qtcount tCopy2(t2);
qtcount t3(origIm3);
qtcount tCopy3(t3);
// prune the quadtree
tCopy1.prune(30000);
tCopy2.prune(10000);
tCopy3.prune(1000);
// render the quadtree
PNG ppic1 = tCopy1.render();
PNG ppic2 = tCopy2.render();
PNG ppic3 = tCopy3.render();
ppic1.writeToFile("images/out/output-prunedflower.png");
ppic2.writeToFile("images/out/output-prunedgarden.png");
ppic3.writeToFile("images/out/output-prunedsky.png");
// use it to build a quadtree
qtvar v1(origIm4);
qtvar vCopy1(v1);
qtvar v2(origIm5);
qtvar vCopy2(v2);
qtvar v3(origIm1);
qtvar vCopy3(v3);
// prune the quadtree
vCopy1.prune(100000);
vCopy2.prune(50000);
vCopy3.prune(1000);
// render the quadtree
PNG vpic1 = vCopy1.render();
PNG vpic2 = vCopy2.render();
PNG vpic3 = vCopy3.render();
vpic1.writeToFile("images/out/output-prunedsnowMountain-var.png");
vpic2.writeToFile("images/out/output-prunedvancouverDowntown-var.png");
vpic3.writeToFile("images/out/output-prunedflower-var.png");
// comparisons
qtcount countcomp(origIm1);
qtvar varcomp(origIm1);
countcomp.prune(countcomp.idealPrune(10000));
varcomp.prune(varcomp.idealPrune(10000));
/*
// I wrote two member functions to help me understand the different
// compression strategies.
cout << "count: " << countcomp.count() << endl;
cout << "count dim: " << countcomp.dimsum() << endl;
cout << "var: " << varcomp.count() << endl;
cout << "var dim: " << varcomp.dimsum() << endl;
*/
PNG countpng = countcomp.render();
PNG varpng = varcomp.render();
countpng.writeToFile("images/out/output-comp-count-flower.png");
varpng.writeToFile("images/out/output-comp-var-flower.png");
return 0;
}