Leptonica 1.68
C Image Processing Library

contrasttest.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  * contrasttest.c
00018  *
00019  */
00020 
00021 #include <math.h>
00022 #include "allheaders.h"
00023 
00024 #define   NPLOTS       5
00025 
00026 main(int    argc,
00027      char **argv)
00028 {
00029 char        *filein, *fileout;
00030 char         bigbuf[512];
00031 l_int32      iplot;
00032 l_float32    factor;    /* scaled width of atan curve */
00033 l_float32    fact[NPLOTS] = {.2, 0.4, 0.6, 0.8, 1.0};
00034 GPLOT       *gplot;
00035 NUMA        *na, *nax;
00036 PIX         *pixs, *pixd;
00037 static char  mainName[] = "contrasttest";
00038 
00039     if (argc != 4)
00040         return ERROR_INT(" Syntax:  contrasttest filein factor fileout",
00041                mainName, 1);
00042 
00043     filein = argv[1];
00044     factor = atof(argv[2]);
00045     fileout = argv[3];
00046 
00047     if ((pixs = pixRead(filein)) == NULL)
00048         return ERROR_INT("pixs not made", mainName, 1);
00049             
00050 #if 0
00051     startTimer();
00052     pixContrastTRC(pixs, pixs, factor);
00053     fprintf(stderr, "Time for contrast: %7.3f sec\n", stopTimer());
00054     pixWrite(fileout, pixs, IFF_JFIF_JPEG);
00055     pixDestroy(&pixs);
00056 #endif
00057 
00058 #if 0
00059     startTimer();
00060     pixd = pixContrastTRC(NULL, pixs, factor);
00061     fprintf(stderr, "Time for contrast: %7.3f sec\n", stopTimer());
00062     pixWrite(fileout, pixd, IFF_JFIF_JPEG);
00063     pixDestroy(&pixs);
00064     pixDestroy(&pixd);
00065 #endif
00066 
00067     na = numaContrastTRC(factor);
00068     gplotSimple1(na, GPLOT_X11, "junkroot", "contrast trc");
00069     numaDestroy(&na);
00070 
00071 #if 1     /* plot contrast TRC maps */
00072     nax = numaMakeSequence(0.0, 1.0, 256);
00073     gplot = gplotCreate("junkmap", GPLOT_X11,
00074         "Atan mapping function for contrast enhancement",
00075         "value in", "value out");
00076     for (iplot = 0; iplot < NPLOTS; iplot++) {
00077         na = numaContrastTRC(fact[iplot]);
00078         sprintf(bigbuf, "factor = %3.1f", fact[iplot]);
00079         gplotAddPlot(gplot, nax, na, GPLOT_LINES, bigbuf);
00080         numaDestroy(&na);
00081     }
00082     gplotMakeOutput(gplot);
00083     gplotDestroy(&gplot);
00084     numaDestroy(&nax);
00085 #endif
00086 
00087     return 0;
00088 }
00089 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines