Skip to content
Snippets Groups Projects
Commit 86c98a42 authored by poulpe's avatar poulpe
Browse files

[Update] Add flag for symmetry options

parent 8db2d0f6
No related branches found
No related tags found
No related merge requests found
......@@ -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(),
};
......@@ -49,19 +53,39 @@ int main(int argc, const char **argv)
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);
if(symmetry_select != 0)
{
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_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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment