examples/test_pnm/test_pnm.c

Go to the documentation of this file.
00001 /*
00002    libit - Library for basic source and channel coding functions
00003    Copyright (C) 2005-2005 Vivien Chappelier, Herve Jegou
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 /** @file test_pnm.c Test program for pnm file */
00021 
00022 #include <it/io.h>
00023 #include <it/mat.h>
00024 
00025 int main ()
00026 {
00027   const char *filename_in = "../data/test.pgm";
00028   const char *filename_out = "out.pgm";
00029   char pnm_type, comments[1000];
00030   int  width, height, maxval;
00031   imat m;
00032 
00033   pnm_info (filename_in, &pnm_type, &width, &height, &maxval, comments, 1000);
00034   printf ("file name = %s\npnm type = %c\n%dx%d -> maxval=%d\ncomments=%s\n",
00035     filename_in, pnm_type, width, height, maxval, "");
00036 
00037   m = imat_pgm_read (filename_in);
00038 
00039   printf
00040     ("height(m) = %d\tmaxheight(m) = %d\nwidth(m) = %d\tmaxwidth(m) = %d\n",
00041      imat_height (m), imat_height_max (m), imat_width (m),
00042      imat_width_max (m));
00043 
00044   imat_pgm_write (filename_out, m);
00045   imat_delete (m);
00046   return 0;
00047 }

Hosted by
Copyright (C) 2005-2006 Hervé Jégou
Vivien Chappelier
Francois Cayre
libit logo courtesy of Jonathan Delhumeau