forked from bbbbyang/QuadTree-Segmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
42 lines (32 loc) · 1003 Bytes
/
Copy pathSource.cpp
File metadata and controls
42 lines (32 loc) · 1003 Bytes
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
//----------------------------------------------------------------------------
// BINGYANG LIU
// OPENCV 3.0.0
//----------------------------------------------------------------------------
// The image size should be 2^k * 2^k
#include "QuadTree.h"
#include <iostream>
#include <vector>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
using namespace std;
using namespace cv;
int main(){
// Load image to gray level and resize the image
// For Gray Scale
Mat Img = imread("house.tif", 0);
// Get boundarybox area of the image
int Rows = Img.rows;
int Cols = Img.cols;
BoundaryBox Area(Vector2(0, 0), Vector2(Rows, Cols));
// Implement a quadtree
QuadTree Tree(Area, Img);
Tree.CreateQuadTree();
Tree.Mark_The_LeafNode(Tree.Root);
resize(Img, Img, Size(512, 512), 0, 0, 1);
namedWindow("Segment Image");
imshow("Segment Image", Img);
imwrite("QuadTreeSegmentation.tif", Img);
waitKey();
return 1;
}