/* $Id: cpl_detector_body.h,v 1.2 2007/07/06 13:57:49 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 #define CPL_IMAGE_GET_DATA cpl_image_get_data_double #elif CPL_CLASS == CPL_CLASS_FLOAT #define CPL_TYPE float #define CPL_TYPE_T CPL_TYPE_FLOAT #define CPL_IMAGE_GET_DATA cpl_image_get_data_float #else #undef CPL_TYPE #undef CPL_TYPE_T #undef CPL_IMAGE_GET_DATA #endif #if CPL_OPERATION == CPL_DET_CLEAN_BAD_PIX case CPL_TYPE_T: { CPL_TYPE * pi ; pi = CPL_IMAGE_GET_DATA(in) ; while ((nbad=cpl_image_count_rejected(in)) > 0) { /* Get the bad pixel map */ bpm_cur = cpl_image_get_bpm(in) ; bpm = cpl_mask_duplicate(bpm_cur) ; pbpm = cpl_mask_get_data(bpm) ; pbpm_cur = cpl_mask_get_data_const(bpm_cur) ; cpl_ensure_code(pbpm_cur, CPL_ERROR_ILLEGAL_OUTPUT) ; /* Try to clean each bad pixel */ for (j=0 ; j=0) if (pbpm_cur[pos-1] == CPL_BINARY_0) { sum_pix += (double)pi[pos-1] ; nb_pix++ ; } if (pos+1=0) if (pbpm_cur[pos-nx+1] == CPL_BINARY_0) { sum_pix += (double)pi[pos-nx+1] ; nb_pix++ ; } if (pos-nx-1>=0) if (pbpm_cur[pos-nx-1] == CPL_BINARY_0) { sum_pix += (double)pi[pos-nx-1] ; nb_pix++ ; } if (pos-nx>=0) if (pbpm_cur[pos-nx] == CPL_BINARY_0) { sum_pix += (double)pi[pos-nx] ; nb_pix++ ; } if (nb_pix > 0) { /* Successfully recomputed */ sum_pix /= nb_pix ; pi[pos] = (CPL_TYPE)sum_pix ; pbpm[pos] = CPL_BINARY_0 ; } } } } /* Update the bad pixel map in in */ cpl_image_reject_from_mask(in, bpm) ; cpl_mask_delete(bpm) ; } break ; } #endif #undef CPL_TYPE #undef CPL_TYPE_T #undef CPL_IMAGE_GET_DATA