Leptonica 1.68
C Image Processing Library
|
00001 /*====================================================================* 00002 - Copyright (C) 2001 Leptonica. All rights reserved. 00003 - This software is distributed in the hope that it will be 00004 - useful, but with NO WARRANTY OF ANY KIND. 00005 - No author or distributor accepts responsibility to anyone for the 00006 - consequences of using this software, or for whether it serves any 00007 - particular purpose or works at all, unless he or she says so in 00008 - writing. Everyone is granted permission to copy, modify and 00009 - redistribute this source code, for commercial or non-commercial 00010 - purposes, with the following restrictions: (1) the origin of this 00011 - source code must not be misrepresented; (2) modified versions must 00012 - be plainly marked as such; and (3) this notice may not be removed 00013 - or altered from any source or modified source distribution. 00014 *====================================================================*/ 00015 00016 /* 00017 * flipselgen.c 00018 * 00019 * Generates dwa code for hit-miss transform (hmt) that is 00020 * used in pixPageFlipDetectDWA(). 00021 * 00022 * Results are two files: 00023 * fmorphgen.3.c 00024 * fmorphgenlow.3.c 00025 * using INDEX = 3. 00026 */ 00027 00028 #include <stdio.h> 00029 #include <stdlib.h> 00030 #include "allheaders.h" 00031 00032 #define INDEX 3 00033 #define DFLAG 1 00034 00035 /* Sels for pixPageFlipDetectDWA() */ 00036 static const char *textsel1 = "x oo " 00037 "x oOo " 00038 "x o " 00039 "x " 00040 "xxxxxx"; 00041 00042 static const char *textsel2 = " oo x" 00043 " oOo x" 00044 " o x" 00045 " x" 00046 "xxxxxx"; 00047 00048 static const char *textsel3 = "xxxxxx" 00049 "x " 00050 "x o " 00051 "x oOo " 00052 "x oo "; 00053 00054 static const char *textsel4 = "xxxxxx" 00055 " x" 00056 " o x" 00057 " oOo x" 00058 " oo x"; 00059 00060 main(int argc, 00061 char **argv) 00062 { 00063 SEL *sel1, *sel2, *sel3, *sel4; 00064 SELA *sela; 00065 PIX *pix, *pixd; 00066 PIXA *pixa; 00067 static char mainName[] = "flipselgen"; 00068 00069 if (argc != 1) 00070 exit(ERROR_INT(" Syntax: flipselgen", mainName, 1)); 00071 00072 sela = selaCreate(0); 00073 sel1 = selCreateFromString(textsel1, 5, 6, "flipsel1"); 00074 sel2 = selCreateFromString(textsel2, 5, 6, "flipsel2"); 00075 sel3 = selCreateFromString(textsel3, 5, 6, "flipsel3"); 00076 sel4 = selCreateFromString(textsel4, 5, 6, "flipsel4"); 00077 selaAddSel(sela, sel1, NULL, 0); 00078 selaAddSel(sela, sel2, NULL, 0); 00079 selaAddSel(sela, sel3, NULL, 0); 00080 selaAddSel(sela, sel4, NULL, 0); 00081 00082 pixa = pixaCreate(4); 00083 pix = selDisplayInPix(sel1, 23, 2); 00084 pixDisplayWithTitle(pix, 100, 100, "sel1", DFLAG); 00085 pixaAddPix(pixa, pix, L_INSERT); 00086 pix = selDisplayInPix(sel2, 23, 2); 00087 pixDisplayWithTitle(pix, 275, 100, "sel2", DFLAG); 00088 pixaAddPix(pixa, pix, L_INSERT); 00089 pix = selDisplayInPix(sel3, 23, 2); 00090 pixDisplayWithTitle(pix, 450, 100, "sel3", DFLAG); 00091 pixaAddPix(pixa, pix, L_INSERT); 00092 pix = selDisplayInPix(sel4, 23, 2); 00093 pixDisplayWithTitle(pix, 625, 100, "sel4", DFLAG); 00094 pixaAddPix(pixa, pix, L_INSERT); 00095 00096 pixd = pixaDisplayTiled(pixa, 800, 0, 15); 00097 pixDisplayWithTitle(pixd, 100, 300, "allsels", DFLAG); 00098 pixDestroy(&pixd); 00099 pixaDestroy(&pixa); 00100 00101 if (fhmtautogen(sela, INDEX, NULL)) 00102 exit(ERROR_INT(" Generation failed", mainName, 1)); 00103 00104 selaDestroy(&sela); 00105 return 0; 00106 } 00107