Skip to content
Snippets Groups Projects
Commit 0a17cff8 authored by stefan.lazic's avatar stefan.lazic
Browse files

added more console outputs

parent add6d956
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -57,45 +57,59 @@ int main(int argc, char *argv[]) {
pgm *p_pgm1 = calloc(1, sizeof(pgm)); // create p_pgm1
alloc_test(p_pgm1);
print_applying("read PGM to matrix1");
run_func(pgm_read(p_pgm1, argv[1])); // pgm read argv[1] > p_pgm1
int n_max = ceil(log2(p_pgm1->mat.m)); // calculate quadtree levels, 2^x = 512, x = log2(512), mat.m = 512 (for our test images) -> x = 9
print_applying("create qtree1");
quadtree p_qtree1 = quadtree_create(n_max); // create quadtree
alloc_test(p_qtree1);
print_applying("matrix1 to qtree1");
// quadtree to matrix
run_func(matrix_to_quadtree(p_qtree1, &p_pgm1->mat, 0, n_max, p_pgm1->mat.m/2, p_pgm1->mat.m/2, p_pgm1->mat.n/2));
print_applying("horizontal symmetry qtree1");
run_func(quadtree_horizontal_symmmetry(p_qtree1)); // symmetry
run_func(quadtree_vertical_symmmetry(p_qtree1)); // symmetry
//print_applying("horizontal symmetry");
//run_func(quadtree_vertical_symmmetry(p_qtree1)); // symmetry
//run_func(quadtree_central_symmmetry(p_qtree1)); // symmetry
print_applying("compression qtree1");
quadtree_compress(p_qtree1, atof(argv[3])); // compression
print_applying("write qtree1 to temp.qtree");
run_func(quadtree_write_file(p_qtree1, "temp.qtree", n_max)); // write compressed file to temp.qtree
// ------------------------------------------------------------------------- read compressed file, build qtree, build matrix, output pgm
print_applying("read temp.qtree to qtree2");
quadtree p_qtree2 = quadtree_read_file("temp.qtree", &n_max); // read quadtree file, n_max will be overwritten
alloc_test(p_qtree2);
print_applying("create matrix2");
pgm *p_pgm2 = calloc(1, sizeof(pgm)); // create p_pgm2
alloc_test(p_pgm2);
p_pgm2->max = 255;
run_func(matrix_create(&p_pgm2->mat, pow(2, n_max), pow(2, n_max))); // create matrix
print_applying("qtree1 to matrix1");
print_applying("qtree2 to matrix2");
// fill matrix from quadtree
run_func(quadtree_to_matrix(p_qtree1, &p_pgm1->mat, 0, n_max, p_pgm1->mat.m/2, p_pgm1->mat.m/2, p_pgm1->mat.n/2, -1));
run_func(quadtree_to_matrix(p_qtree2, &p_pgm2->mat, 0, n_max, p_pgm2->mat.m/2, p_pgm2->mat.m/2, p_pgm2->mat.n/2, -1));
if(argc > 4 && (int)atof(argv[4]) == 1){ // if 4th parameter is given, write pgm2 to output, otherwise pgm1
print_applying("write matrix2 to PGM");
run_func(pgm_write(p_pgm2, argv[2])); // pgm write p_pgm1> argv[2]
}
else{
print_applying("write matrix1 to PGM");
run_func(pgm_write(p_pgm1, argv[2])); // pgm write p_pgm2 > argv[2]
}
print_applying("cleanup");
run_func(quadtree_destroy(p_qtree1)); // cleanup
run_func(quadtree_destroy(p_qtree2));
run_func(pgm_destroy(p_pgm1));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment