/* $Id: cpl_image_gen_body.h,v 1.14 2007/06/28 13:13:46 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 */ /* Type dependent macros */ #if CPL_CLASS == CPL_CLASS_DOUBLE #define CPL_TYPE double #define CPL_TYPE_T CPL_TYPE_DOUBLE #elif CPL_CLASS == CPL_CLASS_FLOAT #define CPL_TYPE float #define CPL_TYPE_T CPL_TYPE_FLOAT #elif CPL_CLASS == CPL_CLASS_INT #define CPL_TYPE int #define CPL_TYPE_T CPL_TYPE_INT #else #undef CPL_TYPE #undef CPL_TYPE_T #endif #if CPL_OPERATION == CPL_IMAGE_GEN_NOISE_UNIFORM case CPL_TYPE_T: { CPL_TYPE * pi ; pi = (CPL_TYPE*)ima->pixels ; /* Compute the pixels values */ for (j=0 ; jny ; j++) for (i=0 ; inx ; i++) pi[i+j*ima->nx] = (CPL_TYPE)(min_pix + cpl_drand()*(max_pix-min_pix)); break ; } #elif CPL_OPERATION == CPL_IMAGE_GEN_GAUSSIAN case CPL_TYPE_T: { CPL_TYPE * pi ; pi = (CPL_TYPE*)ima->pixels ; /* Compute the pixels values */ for (j=0 ; jny ; j++) { for (i=0 ; inx ; i++) { x = (double)(i+1) - (double)xcen ; y = (double)(j+1) - (double)ycen ; pi[i+j*ima->nx]=(CPL_TYPE)cpl_gaussian_2d(x,y,norm,sig_x,sig_y); } } break ; } #elif CPL_OPERATION == CPL_IMAGE_GEN_POLYNOMIAL case CPL_TYPE_T: { CPL_TYPE * pi ; pi = (CPL_TYPE*)ima->pixels ; /* Compute the pixels values */ x = cpl_vector_new(2) ; xdata = cpl_vector_get_data(x) ; for (j=0 ; jny ; j++) { for (i=0 ; inx ; i++) { xdata[0] = (double)(startx + i * stepx) ; xdata[1] = (double)(starty + j * stepy) ; pi[i+j*ima->nx] = (CPL_TYPE)cpl_polynomial_eval(poly, x) ; } } cpl_vector_delete(x) ; break ; } #endif #undef CPL_TYPE #undef CPL_TYPE_T