~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-libs/demo/example/compare.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU Lesser General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU Lesser General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU Lesser General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  **********
 20  * 
 21  * Program :    TINA
 22  * File    :  $Source: /home/tina/cvs/tina-libs/demo/example/compare.c,v $
 23  * Date    :  $Date: 2007/02/15 01:52:29 $
 24  * Version :  $Revision: 1.2 $
 25  * CVS Id  :  $Id: compare.c,v 1.2 2007/02/15 01:52:29 paul Exp $
 26  *
 27  * Author  :  Tony lacey (a.lacey@man.ac.uk)
 28  *
 29  * Notes   :
 30  * 
 31  * Demonstration program for using tina libraries
 32  * This program complements example.c by loading the resultant image
 33  * and comparing (i.e. subtracting) it from the original then ensuring
 34  * that the max and min image values are 0.0
 35  * It expects the files to be called result.pgm and example.pgm
 36  * 
 37  *********
 38 */
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <stdio.h>
 45 #include <stdlib.h>
 46 #include <string.h>
 47 #include <limits.h>
 48 #include <tina/image/imgDef.h>
 49 #include <tina/image/imgPro.h>
 50 #include <tina/file/fileDef.h>
 51 #include <tina/file/filePro.h>
 52 
 53 int main(int argvc, char **argv)
 54 {
 55         Imrect *im1, *im2, *im3;
 56         float   min, max;
 57         char result[PATH_MAX+1] = ".", *srcdir;
 58 
 59         srcdir = getenv ("srcdir"); /* Should be set by Makefile */
 60         if (srcdir)
 61           strncpy (result, srcdir, sizeof (result));
 62         strncat (result, "/result.pgm", sizeof (result));
 63 
 64         /*
 65          * load a pgm format image and return a tina Imrect
 66          * (the basic tina image structure)
 67          */
 68         printf("Reading distributed image %s\n", result);
 69         if ((im1 = pgm_read_image(result)) == NULL)
 70         {
 71                 printf("Error reading pgm image file\n");
 72                 exit(-1);
 73         }
 74 
 75         /*
 76          * load a pgm format image and return a tina Imrect
 77          * (the basic tina image structure)
 78          */     
 79         printf("Reading generated image example.pgm\n");
 80         if ((im2 = pgm_read_image("example.pgm")) == NULL)
 81         {
 82                 printf("Error reading pgm image file, have you run example?\n");
 83                 exit(-1);
 84         }
 85 
 86         /*
 87          * calcuate the difference between the two images and
 88          * cast the image returned to type float (was probably
 89          * of type char as pgm is 8 bit)
 90          */     
 91         im3 = im_cast(im_diff(im1, im2), float_v);
 92         
 93         /*
 94          * find the min and max values in the image and store in 
 95          * variables at locations min and max
 96          */
 97         imf_minmax(im3, &min, &max);
 98         
 99         if (min == 0.0 && max == 0.0)
100                 printf("Images are the same!\n");
101         else
102                 printf("Images differ - max = %4.2f min = %4.2f", max, min);
103                 
104         /*
105          * free the memory used by the images
106          */
107         im_free(im1);
108         im_free(im2);
109         im_free(im3);
110 
111         return 0;
112 }
113 
114 
115 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.