Leptonica 1.68
C Image Processing Library

ccthin2_reg.c

Go to the documentation of this file.
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  * ccthin2_reg.c
00018  *
00019  *   Tests the examples in pixThinExamples()
00020  */
00021 
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include "allheaders.h"
00025 
00026 
00027 main(int    argc,
00028      char **argv)
00029 {
00030 l_int32      index, maxiters, type;
00031 BOX         *box;
00032 PIX         *pix, *pixs, *pixd, *pixt;
00033 PIXA        *pixa;
00034 static char  mainName[] = "ccthin2_reg";
00035 
00036     if (argc != 1 && argc != 3)
00037         exit(ERROR_INT(" Syntax: ccthin2_reg [index maxiters]", mainName, 1));
00038 
00039     pixDisplayWrite(NULL, 0);
00040     if ((pix = pixRead("feyn.tif")) == NULL)
00041         exit(ERROR_INT("pix not made", mainName, 1));
00042     box = boxCreate(683, 799, 970, 479);
00043     pixs = pixClipRectangle(pix, box, NULL);
00044     pixDisplayWrite(pixs, 1);
00045 
00046         /* Just do one of the examples */
00047     if (argc == 3) {
00048         index = atoi(argv[1]);
00049         maxiters = atoi(argv[2]);
00050         if (index <= 7)
00051             type = L_THIN_FG;
00052         else
00053             type = L_THIN_BG;
00054         pixt = pixThinExamples(pixs, type, index, maxiters,
00055                                "/tmp/junksels.png");
00056         pixDisplay(pixt, 100, 100);
00057         pixDisplayWrite(pixt, 1);
00058         pixDestroy(&pixt);
00059         pixDisplayMultiple("/tmp/junk_write_display*");
00060         return 0;
00061     }
00062 
00063         /* Do all the examples */
00064     pixt = pixThinExamples(pixs, L_THIN_FG, 1, 0, "/tmp/junksel_example1.png");
00065     pixDisplayWrite(pixt, 1);
00066     pixDestroy(&pixt);
00067     pixt = pixThinExamples(pixs, L_THIN_FG, 2, 0, "/tmp/junksel_example2.png");
00068     pixDisplayWrite(pixt, 1);
00069     pixDestroy(&pixt);
00070     pixt = pixThinExamples(pixs, L_THIN_FG, 3, 0, "/tmp/junksel_example3.png");
00071     pixDisplayWrite(pixt, 1);
00072     pixDestroy(&pixt);
00073     pixt = pixThinExamples(pixs, L_THIN_FG, 4, 0, "/tmp/junksel_example4.png");
00074     pixDisplayWrite(pixt, 1);
00075     pixDestroy(&pixt);
00076     pixt = pixThinExamples(pixs, L_THIN_FG, 5, 0, "/tmp/junksel_example5.png");
00077     pixDisplayWrite(pixt, 1);
00078     pixDestroy(&pixt);
00079     pixt = pixThinExamples(pixs, L_THIN_FG, 6, 0, "/tmp/junksel_example6.png");
00080     pixDisplayWrite(pixt, 1);
00081     pixDestroy(&pixt);
00082     pixt = pixThinExamples(pixs, L_THIN_FG, 7, 0, "/tmp/junksel_example7.png");
00083     pixDisplayWrite(pixt, 1);
00084     pixDestroy(&pixt);
00085     pixt = pixThinExamples(pixs, L_THIN_BG, 8, 5, "/tmp/junksel_example8.png");
00086     pixDisplayWrite(pixt, 1);
00087     pixDestroy(&pixt);
00088     pixt = pixThinExamples(pixs, L_THIN_BG, 9, 5, "/tmp/junksel_example9.png");
00089     pixDisplayWrite(pixt, 1);
00090     pixDestroy(&pixt);
00091 
00092         /* Display the thinning results */
00093     pixa = pixaReadFiles("/tmp", "junk_write_display");
00094     pixd = pixaDisplayTiledAndScaled(pixa, 8, 500, 1, 0, 25, 2);
00095     pixWrite("/tmp/junktiles.jpg", pixd, IFF_JFIF_JPEG);
00096     pixDestroy(&pixd);
00097     pixaDestroy(&pixa);
00098 
00099         /* Display the sels used in the examples */
00100     pixa = pixaReadFiles("/tmp", "junksel_example");
00101     pixd = pixaDisplayTiledInRows(pixa, 1, 500, 1.0, 0, 50, 2);
00102     pixWrite("/tmp/junksels.png", pixd, IFF_PNG);
00103     pixDestroy(&pixd);
00104     pixaDestroy(&pixa);
00105 
00106     pixDestroy(&pix);
00107     pixDestroy(&pixs);
00108     boxDestroy(&box);
00109 
00110     pixDisplayMultiple("/tmp/junk_write_display*");
00111     return 0;
00112 }
00113 
00114 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines