examples/test_filter/test_filter.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_filter.c Test program for filters
00021   \author Vivien Chappelier
00022 */
00023 
00024 #include <it/io.h>
00025 #include <it/mat.h>
00026 #include <it/parser.h>
00027 #include <it/filter.h>
00028 
00029 int main (int argc, char *argv[])
00030 {
00031   const char *image_in = "../data/test.pgm";
00032   const char *image_out = "out.pgm";
00033   mat  m, mt;
00034   mat  filter;
00035   parser_t *parser = parser_init (argc, argv, "test_filter.param", NULL);
00036 
00037   /* Read the image */
00038   m = mat_pgm_read (image_in);
00039   printf ("PGM %dx%d\n", mat_width (m), mat_height (m));
00040 
00041   parser_print (parser);
00042 
00043   /* Read the filter */
00044   filter = parser_get_mat (parser, "Laplace");
00045   mt =
00046     mat_filter_fir (m, filter, mat_width (filter) / 2,
00047         mat_height (filter) / 2);
00048   mat_delete (filter);
00049   mat_pgm_write (image_out, mt);
00050   mat_delete (mt);
00051 
00052   /* Free the allocated resource */
00053   mat_delete (m);
00054 
00055 
00056   return 0;
00057 }

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