Leptonica 1.68
C Image Processing Library

livre_seedgen.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  * livre_seedgen.c
00018  */
00019 
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include "allheaders.h"
00023 
00024 main(int    argc,
00025      char **argv)
00026 {
00027 l_int32      i;
00028 PIX         *pixs, *pixt1, *pixt2, *pixt3, *pixd;
00029 PIXA        *pixa;
00030 static char  mainName[] = "livre_seedgen";
00031 
00032     pixs = pixRead("pageseg2.tif");
00033 
00034     startTimer();
00035     for (i = 0; i < 100; i++) {
00036         pixt1 = pixReduceRankBinaryCascade(pixs, 1, 4, 4, 3);
00037         pixDestroy(&pixt1);
00038     }
00039     fprintf(stderr, "Time: %8.4f sec\n", stopTimer() / 100.);
00040 
00041         /* 4 2x rank reductions (levels 1, 4, 4, 3), followed by 5x5 opening */
00042     pixDisplayWrite(NULL, -1);
00043     pixDisplayWriteFormat(pixs, 4, IFF_PNG);
00044     pixt1 = pixReduceRankBinaryCascade(pixs, 1, 4, 0, 0);
00045     pixDisplayWriteFormat(pixt1, 1, IFF_PNG);
00046     pixt2 = pixReduceRankBinaryCascade(pixt1, 4, 3, 0, 0);
00047     pixDisplayWriteFormat(pixt2, 1, IFF_PNG);
00048     pixOpenBrick(pixt2, pixt2, 5, 5);
00049     pixt3 = pixExpandBinaryReplicate(pixt2, 2);
00050     pixDisplayWriteFormat(pixt3, 1, IFF_PNG);
00051 
00052         /* Generate the output image */
00053     pixa = pixaReadFiles("/tmp", "junk_write_display");
00054     pixd = pixaDisplayTiledAndScaled(pixa, 8, 250, 4, 0, 25, 2);
00055     pixWrite("/tmp/seedgen.png", pixd, IFF_PNG);
00056 
00057     pixDestroy(&pixs);
00058     pixDestroy(&pixt1);
00059     pixDestroy(&pixt2);
00060     pixDestroy(&pixt3);
00061     pixDestroy(&pixd);
00062     pixaDestroy(&pixa);
00063     return 0;
00064 }
00065 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines