/* * This file is part of the ESO SINFONI Pipeline * Copyright (C) 2004,2005 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, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA */ /*---------------------------------------------------------------------------- File name : resampling.c Author : Nicolas Devillard Created on : Jan 04, 1996 Description : resampling routines ---------------------------------------------------------------------------*/ /* $Id: sinfo_resampling.c,v 1.6 2012-03-03 10:18:26 amodigli Exp $ $Author: amodigli $ $Date: 2012-03-03 10:18:26 $ $Revision: 1.6 $ */ #ifdef HAVE_CONFIG_H # include #endif /*--------------------------------------------------------------------------- Includes ---------------------------------------------------------------------------*/ #include #include "sinfo_resampling.h" #include #include "sinfo_globals.h" /*--------------------------------------------------------------------------- Private functions ---------------------------------------------------------------------------*/ static void reverse_tanh_kernel(double * data, int nn) ; static double * sinfo_generate_tanh_kernel(double steep); /**@{*/ /** * @addtogroup sinfo_rec_jitter Image resampling * * TBD */ /*--------------------------------------------------------------------------- Function codes ---------------------------------------------------------------------------*/ /** @name sinfo_generate_interpolation_kernel @memo Generate an interpolation kernel to use in this module. @param kernel_type Type of interpolation kernel. @return 1 newly allocated array of doubles. @doc Provide the name of the kernel you want to generate. Supported kernel types are: \begin{tabular}{ll} NULL & default kernel, currently "tanh" \\ "default" & default kernel, currently "tanh" \\ "tanh" & Hyperbolic tangent \\ "sinc2" & Square sinc \\ "lanczos" & Lanczos2 kernel \\ "hamming" & Hamming kernel \\ "hann" & Hann kernel \end{tabular} The returned array of doubles is ready of use in the various re-sampling functions in this module. It must be deallocated using cpl_free(). */ double * sinfo_generate_interpolation_kernel(const char * kernel_type) { double * tab ; int i ; double x ; double alpha ; double inv_norm ; int samples = KERNEL_SAMPLES ; if (kernel_type==NULL) { tab = sinfo_generate_interpolation_kernel("tanh") ; } else if (!strcmp(kernel_type, "default")) { tab = sinfo_generate_interpolation_kernel("tanh") ; } else if (!strcmp(kernel_type, "sinc")) { tab = cpl_malloc(samples * sizeof(double)) ; tab[0] = 1.0 ; tab[samples-1] = 0.0 ; for (i=1 ; i i) { KERNEL_SW(data[j-1],data[i-1]); KERNEL_SW(data[j],data[i]); } m = n >> 1; while (m>=2 && j>m) { j -= m; m >>= 1; } j += m; } mmax = 2; while (n > mmax) { unsigned long istep = mmax << 1; double theta = 2 * PI_NUMB / mmax; double wtemp = sin(0.5 * theta); double wpr = -2.0 * wtemp * wtemp; double wpi = sin(theta); double wr = 1.0; double wi = 0.0; for (m=1 ; m