Leptonica 1.68
C Image Processing Library

runlengthtest.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  * runlengthtest.c
00018  *
00019  */
00020 
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include "allheaders.h"
00024 
00025 main(int    argc,
00026      char **argv)
00027 {
00028 PIX         *pixs, *pixh, *pixv, *pix, *pixd;
00029 char        *filein, *fileout;
00030 static char  mainName[] = "runlengthtest";
00031 
00032     if (argc != 3)
00033         exit(ERROR_INT(" Syntax:  runlengthtest filein fileout", mainName, 1));
00034 
00035     filein = argv[1];
00036     fileout = argv[2];
00037 
00038     if ((pixs = pixRead(filein)) == NULL)
00039         exit(ERROR_INT("pixs not made", mainName, 1));
00040             
00041     startTimer();
00042     pixh = pixRunlengthTransform(pixs, 0, L_HORIZONTAL_RUNS, 8);
00043     pixv = pixRunlengthTransform(pixs, 0, L_VERTICAL_RUNS, 8);
00044     pix = pixMinOrMax(NULL, pixh, pixv, L_CHOOSE_MAX);
00045     pixd = pixMaxDynamicRange(pix, L_LINEAR_SCALE);
00046     fprintf(stderr, "Total time: %7.3f sec\n", stopTimer());
00047     pixDisplay(pixh, 0, 0);
00048     pixDisplay(pixv, 400, 0);
00049     pixDisplay(pix, 800, 0);
00050     pixDisplay(pixd, 1200, 0);
00051     pixWrite("/tmp/junkpixh.png", pixh, IFF_PNG);
00052     pixWrite("/tmp/junkpixv.png", pixv, IFF_PNG);
00053     pixWrite("/tmp/junkpix.png", pix, IFF_PNG);
00054     pixWrite(fileout, pixd, IFF_PNG);
00055 
00056     pixDestroy(&pixs);
00057     pixDestroy(&pixh);
00058     pixDestroy(&pixv);
00059     pixDestroy(&pix);
00060     pixDestroy(&pixd);
00061     exit(0);
00062 }
00063 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines