-
Notifications
You must be signed in to change notification settings - Fork 0
/
quadTree.h
69 lines (55 loc) · 1.63 KB
/
quadTree.h
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
#ifndef QUADTREE_H
#define QUADTREE_H
#include <iostream>
typedef unsigned char byte;
class QuadTree
{
//Structure for quadTree nodes
struct qnode
{
//x,y,width,height variables for tree node
int x, y, width, height;
//data value for tree node
int pixel;
//pointers to four subdivisions of a tree node
qnode* topLeft = nullptr;
qnode* topRight = nullptr;
qnode* botLeft = nullptr;
qnode* botRight = nullptr;
bool isLeaf = false;
qnode(int xVal, int yVal, int widthVal, int heightVal){
//sets root x and y coordinates to first element in original array
x = xVal, y = yVal;
//sets root width and height variables equal to original image w and h
width = widthVal, height = heightVal;}
~qnode(){delete topLeft; delete topRight; delete botLeft; delete botRight;}
};
public:
//constructor
QuadTree(byte** image, int totWidth, int totHeight, int thresh);
//Destructor
~QuadTree();
//Subdivide function - breaks the image array into 4 more nodes
void subDivide(qnode* newRoot);
//recursive function to build the tree
void buildTreeRecurse(qnode *root);
bool setNodePixel(qnode* n);
void setIntensity(int threshold);
void setCompressedImage(qnode* root);
void setLines();
byte** getCompressedImage();
void getStats();
float getCompressionRatio();
private:
int originalWidth;
int originalHeight;
int lastQFactor;
int qualityFactor;
int nodeTotal;
int leafCount;
qnode* root;
byte** originalImage;
byte** compressedImage;
bool showLines;
};
#endif // !QUADTREE_H