diff --git a/defines.h b/defines.h index 23fe525..2578b24 100644 --- a/defines.h +++ b/defines.h @@ -111,6 +111,7 @@ #define PRINT_INFO (1<<5) #define ADJUST_GRAY (1<<6) #define DEBUG_OUTPUT (1<<7) +#define ASCII_ART_SEGMENTS (1<<8) /* colors used by ssocr */ #define SSOCR_BLACK 0 diff --git a/help.c b/help.c index ef9f687..65568c8 100644 --- a/help.c +++ b/help.c @@ -103,6 +103,7 @@ void usage(char *name, FILE *f) fprintf(f, " -g, --adjust-gray use T1 and T2 as percentages of used values\n"); fprintf(f, " -l, --luminance=KEYWORD compute luminance using formula KEYWORD\n"); fprintf(f, " use -l help for list of KEYWORDS\n"); + fprintf(f, " -S, --ascii-art-segments print recognized segments a ASCII art\n"); fprintf(f, "\nCommands: dilation dilation algorithm (with mask of 1 pixel)\n"); fprintf(f, " erosion erosion algorithm (with mask of 9 pixels)\n"); fprintf(f, " closing [N] closing algorithm\n"); diff --git a/ssocr.1.in b/ssocr.1.in index c08b67a..d53f410 100644 --- a/ssocr.1.in +++ b/ssocr.1.in @@ -142,6 +142,10 @@ the used formula. The default of .I Rec709 should work well in most cases. +.SS -S, --ascii-art-segments +Prints the recognized segments, i.e. the display as seen by +.BR ssocr , +as ASCII art to standard error. .SH COMMANDS .SS dilation Filter image using dilation algorithm. diff --git a/ssocr.c b/ssocr.c index 03c99fd..286dcbc 100644 --- a/ssocr.c +++ b/ssocr.c @@ -178,9 +178,10 @@ int main(int argc, char **argv) {"print-info", 0, 0, 'I'}, /* print image info */ {"adjust-gray", 0, 0, 'g'}, /* use T1 and T2 as perecntages of used vals*/ {"luminance", 1, 0, 'l'}, /* luminance formula */ + {"ascii-art-segments", 0, 0, 'S'}, /* print found segments in ASCII art */ {0, 0, 0, 0} /* terminate long options */ }; - c = getopt_long (argc, argv, "hVt:vaTn:i:d:r:m:o:O:D::pPf:b:Igl:", + c = getopt_long (argc, argv, "hVt:vaTn:i:d:r:m:o:O:D::pPf:b:Igl:S", long_options, &option_index); if (c == -1) break; /* leaves while (1) loop */ switch (c) { @@ -333,6 +334,13 @@ int main(int argc, char **argv) lt = parse_lum(optarg); } break; + case 'S': + flags |= ASCII_ART_SEGMENTS; + if(flags & DEBUG_OUTPUT) { + fprintf(stderr, "flags & ASCII_ART_SEGMENTS=%d\n", + flags & ASCII_ART_SEGMENTS); + } + break; case '?': /* missing argument or character not in optstring */ usage(argv[0],stderr); exit (2); @@ -1222,7 +1230,7 @@ int main(int argc, char **argv) * | | | _| _| |_| |_ |_ | | | |_| |_| * |_| | |_ _| | _| |_| | | |_| _| */ - if(flags & DEBUG_OUTPUT) { + if(flags & (DEBUG_OUTPUT | ASCII_ART_SEGMENTS)) { fputs("Display as seen by ssocr:\n", stderr); /* top row */ for(i=0; i