/* $Id: cpl_image_gen-test.c,v 1.14 2007/11/13 13:13:02 llundin Exp $ * * This file is part of the ESO Common Pipeline Library * Copyright (C) 2001-2004 European Southern Observatory * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * $Author: llundin $ * $Date: 2007/11/13 13:13:02 $ * $Revision: 1.14 $ * $Name: $ */ /*----------------------------------------------------------------------------- Includes -----------------------------------------------------------------------------*/ #include "cpl_memory.h" #include "cpl_image_gen.h" #include "cpl_image_io.h" #include "cpl_tools.h" /*----------------------------------------------------------------------------- Define -----------------------------------------------------------------------------*/ #define IMAGESZ 512 /*----------------------------------------------------------------------------- Main -----------------------------------------------------------------------------*/ int main(void) { cpl_image * imd; cpl_image * imf; cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING); /* Insert tests below */ /* Test cpl_image_fill_noise_uniform() for double image */ imd = cpl_image_new(IMAGESZ, IMAGESZ, CPL_TYPE_DOUBLE) ; if (cpl_image_fill_noise_uniform(imd, -100, 100)!=CPL_ERROR_NONE) { return cpl_test_end(1); } cpl_msg_info("","Time to generate DOUBLE noise %dx%d image: %g", IMAGESZ, IMAGESZ, cpl_tools_get_cputime(CPL_CLOCK_STOP)) ; cpl_image_delete(imd) ; /* Test cpl_image_fill_noise_uniform() for float image */ imf = cpl_image_new(IMAGESZ, IMAGESZ, CPL_TYPE_FLOAT) ; cpl_tools_get_cputime(CPL_CLOCK_START) ; if (cpl_image_fill_noise_uniform(imf, -100, 100)!=CPL_ERROR_NONE) { return cpl_test_end(1); } cpl_msg_info("","Time to generate FLOAT noise %dx%d image: %g", IMAGESZ, IMAGESZ, cpl_tools_get_cputime(CPL_CLOCK_STOP)) ; cpl_image_delete(imf) ; /* Test cpl_image_fill_gaussian() for double image */ imd = cpl_image_new(IMAGESZ, IMAGESZ, CPL_TYPE_DOUBLE) ; cpl_tools_get_cputime(CPL_CLOCK_START) ; if (cpl_image_fill_gaussian(imd, IMAGESZ/4, IMAGESZ/4, 1.0, 100, 100) != CPL_ERROR_NONE) { return cpl_test_end(1); } cpl_msg_info("","Time to generate DOUBLE gaussian %dx%d image: %g", IMAGESZ, IMAGESZ, cpl_tools_get_cputime(CPL_CLOCK_STOP)) ; cpl_image_delete(imd) ; /* Test cpl_image_fill_gaussian() for float image */ imf = cpl_image_new(IMAGESZ, IMAGESZ, CPL_TYPE_FLOAT) ; cpl_tools_get_cputime(CPL_CLOCK_START) ; if (cpl_image_fill_gaussian(imf, 3*IMAGESZ/4, 3*IMAGESZ/4, 1.0, 100, 100) != CPL_ERROR_NONE) { return cpl_test_end(1); } cpl_msg_info("","Time to generate FLOAT gaussian %dx%d image: %g", IMAGESZ, IMAGESZ, cpl_tools_get_cputime(CPL_CLOCK_STOP)) ; cpl_image_delete(imf) ; /* Test cpl_image_fill_test_create() */ cpl_tools_get_cputime(CPL_CLOCK_START) ; if ((imd = cpl_image_fill_test_create(IMAGESZ, IMAGESZ)) == NULL) { return cpl_test_end(1); } cpl_msg_info("","Time to generate the standard %dx%d test image: %g", IMAGESZ, IMAGESZ, cpl_tools_get_cputime(CPL_CLOCK_STOP)) ; cpl_tools_get_cputime(CPL_CLOCK_START) ; cpl_image_delete(imd) ; /* End of tests */ return cpl_test_end(0); }