Leptonica 1.68
C Image Processing Library

falsecolortest.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  * falsecolortest.c
00018  */
00019 
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 
00023 #include "allheaders.h"
00024 
00025 #define   DEPTH     16    /* set to either 8 or 16 */
00026 #define   WIDTH     768
00027 #define   HEIGHT    100
00028 
00029 
00030 main(int    argc,
00031      char **argv)
00032 {
00033 PIX            *pixs, *pixd, *pixt;
00034 l_int32         i, j, maxval, val;
00035 l_float32       gamma;
00036 static char     mainName[] = "falsecolortest";
00037 
00038     if (argc != 2)
00039         exit(ERROR_INT(" Syntax:  falsecolortest gamma", mainName, 1));
00040 
00041     gamma = atof(argv[1]);
00042     maxval = 0xff;
00043     if (DEPTH == 16)
00044         maxval = 0xffff;
00045 
00046     pixs = pixCreate(WIDTH, HEIGHT, DEPTH);
00047     for (i = 0; i < HEIGHT; i++) {
00048         for (j = 0; j < WIDTH; j++) {
00049             val = maxval * j / WIDTH;
00050             pixSetPixel(pixs, j, i, val);
00051         }
00052     }
00053     fprintf(stderr, "before depth = %d\n", pixGetDepth(pixs));
00054     pixWrite("/tmp/junkout16.png", pixs, IFF_PNG);
00055     pixt = pixRead("/tmp/junkout16.png");
00056     pixWrite("/tmp/junkoutafter.png", pixt, IFF_PNG);
00057     fprintf(stderr, "after depth = %d\n", pixGetDepth(pixt));
00058 
00059     pixd = pixConvertGrayToFalseColor(pixt, gamma);
00060     pixDisplay(pixd, 50, 50);
00061     pixWrite("/tmp/junkout.png", pixd, IFF_PNG);
00062     pixDestroy(&pixs);
00063     pixDestroy(&pixt);
00064     pixDestroy(&pixd);
00065     return 0;
00066 }
00067 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines