Leptonica 1.68
C Image Processing Library

graymorphtest.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  * graymorphtest.c
00018  *
00019  *     Implements basic grayscale morphology; tests speed
00020  *
00021  */
00022 
00023 #include "allheaders.h"
00024 
00025 
00026 main(int    argc,
00027      char **argv)
00028 {
00029 char           *filein, *fileout;
00030 l_int32         wsize, hsize, w, h;
00031 PIX            *pixs, *pixd;
00032 static char     mainName[] = "graymorphtest";
00033 
00034     if (argc != 5)
00035         exit(ERROR_INT(" Syntax:  graymorphtest wsize, hsizefilein fileout",
00036                        mainName, 1));
00037 
00038     filein = argv[1];
00039     wsize = atoi(argv[2]);
00040     hsize = atoi(argv[3]);
00041     fileout = argv[4];
00042 
00043     if ((pixs = pixRead(filein)) == NULL)
00044         exit(ERROR_INT("pix not made", mainName, 1));
00045 
00046     w = pixGetWidth(pixs);
00047     h = pixGetHeight(pixs);
00048 
00049     /* ---------- Choose an operation ----------  */
00050 #if 1
00051     pixd = pixDilateGray(pixs, wsize, hsize);
00052     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00053     pixDestroy(&pixd);
00054 #elif 0
00055     pixd = pixErodeGray(pixs, wsize, hsize);
00056     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00057     pixDestroy(&pixd);
00058 #elif 0
00059     pixd = pixOpenGray(pixs, wsize, hsize);
00060     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00061     pixDestroy(&pixd);
00062 #elif 0
00063     pixd = pixCloseGray(pixs, wsize, hsize);
00064     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00065     pixDestroy(&pixd);
00066 #elif 0
00067     pixd = pixTophat(pixs, wsize, hsize, TOPHAT_WHITE);
00068     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00069     pixDestroy(&pixd);
00070 #elif 0
00071     pixd = pixTophat(pixs, wsize, hsize, TOPHAT_BLACK);
00072     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00073     pixDestroy(&pixd);
00074 #endif
00075 
00076 
00077     /* ---------- Speed ----------  */
00078 #if 0 
00079     startTimer();
00080     pixd = pixCloseGray(pixs, wsize, hsize);
00081     fprintf(stderr, " Speed is %6.2f MPix/sec\n",
00082           (l_float32)(4 * w * h) / (1000000. * stopTimer()));
00083     pixWrite(fileout, pixd, IFF_PNG);
00084 #endif
00085 
00086     pixDestroy(&pixs);
00087     exit(0);
00088 }
00089 
00090 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines