diff --git a/main.c b/main.c
index b3d204b681994dad21c6d1360c449589132cb867..0fe69a5d9003b9078edd661bd40f9f9b75857e2c 100644
--- a/main.c
+++ b/main.c
@@ -21,12 +21,16 @@ int main(int argc, const char **argv)
char *output = NULL;
int32_t level = 0;
int verbose = false;
+ int uncompress = false;
+ int symmetry_select = 0; //
struct argparse_option options[] = {
OPT_HELP(),
OPT_STRING('f', "file", &file, "file to use with library", NULL, 0, 0),
OPT_INTEGER('l', "level", &level, "compression level", NULL, 0, 0),
OPT_STRING('o', "output", &output, "output name of file after program use", NULL, 0, 0),
OPT_BOOLEAN('v', "verbose", &verbose, "more verbose output", NULL, 0, 0),
+ OPT_BOOLEAN(0, "uncompress", &uncompress, "disable compress", NULL, 0, 0),
+ OPT_INTEGER(0, "symmetry", &symmetry_select, "select symmetry to apply : \n\t1 : Horizontal\n\t2 : Vertical\n\t3 : Central\n", NULL, 0, 0),
OPT_END(),
};
@@ -41,27 +45,47 @@ int main(int argc, const char **argv)
pgm_read_from_file(p, file);
uint32_t val = quadtree_get_depth_from_image_size(p->pixels.col);
- if(verbose)
+ if (verbose)
{
- printf("Image input\nx : %d\ty : %d,grayscale : %d\n",p->pixels.lin,p->pixels.col,p->max);
+ printf("Image input\nx : %d\ty : %d,grayscale : %d\n", p->pixels.lin, p->pixels.col, p->max);
}
node *tree = quadtree_tree_create(val);
quadtree_matrix2tree(&p->pixels, tree);
-
-
-
pgm *pp = malloc(1 * sizeof(pgm));
pp->max = p->max;
matrix_alloc(&pp->pixels, p->pixels.lin, p->pixels.col);
- quadtree_moyenne(tree);
- if (verbose)
+ if(symmetry_select != 0)
{
- printf("Compressed level : %d\n",level);
+ if(verbose){printf("Apply %s\n",(symmetry_select == 1)?"horizontal symmetry":(symmetry_select == 2)?"vertical symmetry":"central symmetry");}
+ switch (symmetry_select)
+ {
+ case 1: // Horizontal
+ quadtree_horizontal_symetry(tree);
+ break;
+ case 2: // Horizontal
+ quadtree_vertical_symetry(tree);
+ break;
+ case 3: // Horizontal
+ quadtree_central_symetry(tree);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (!uncompress)
+ {
+ quadtree_moyenne(tree);
+ if (verbose)
+ {
+ printf("Compressed level : %d\n", level);
+ }
+ quadtree_compress(tree, level);
}
- quadtree_compress(tree, level);
quadtree_tree2matrix(tree, &pp->pixels);
pgm_write_from_file(pp, output);
@@ -72,7 +96,8 @@ int main(int argc, const char **argv)
free(p);
free(pp);
}
- else if (argc == 0) {
+ else if (argc == 0)
+ {
argparse_usage(&argparse);
}