00001 00002 /*---------------------------------------------------------------------------- 00003 E.S.O. 00004 ----------------------------------------------------------------------------- 00005 File name : resampling.h 00006 Author : Nicolas Devillard 00007 Created on : Jan 04, 1996 00008 Language : ANSI C 00009 Description : resampling routines 00010 ---------------------------------------------------------------------------*/ 00011 00012 /* 00013 00014 $Id: resampling.h,v 1.2 2005/04/19 09:15:42 amodigli Exp $ 00015 $Author: amodigli $ 00016 $Date: 2005/04/19 09:15:42 $ 00017 $Revision: 1.2 $ 00018 00019 */ 00020 00021 #ifndef _RESAMPLING_H_ 00022 #define _RESAMPLING_H_ 00023 00024 /*---------------------------------------------------------------------------- 00025 * Includes 00026 *--------------------------------------------------------------------------*/ 00027 00028 #include "image_handling.h" 00029 #include "matrix.h" 00030 #include "poly2d.h" 00031 00032 00033 /*---------------------------------------------------------------------------- 00034 * Defines 00035 *--------------------------------------------------------------------------*/ 00036 00037 00038 #define TRANSFO_AFFINE 0 00039 #define TRANSFO_DEG2 1 00040 #define TRANSFO_HOMOGRAPHIC 2 00041 00042 00043 /* 00044 * Kernel definition in terms of sampling 00045 */ 00046 00047 00048 /* Number of tabulations in kernel */ 00049 #define TABSPERPIX (1000) 00050 #define KERNEL_WIDTH (2.0) 00051 #define KERNEL_SAMPLES (1+(int)(TABSPERPIX * KERNEL_WIDTH)) 00052 00053 #define TANH_STEEPNESS (5.0) 00054 00055 00056 /*---------------------------------------------------------------------------- 00057 * Function ANSI C prototypes 00058 *--------------------------------------------------------------------------*/ 00059 00060 00061 /*--------------------------------------------------------------------------- 00062 * Function : shift_image() 00063 * In : OneImage, shift parameters in x and y, interpolation kernel 00064 * Out : OneImage 00065 * Job : Shifts an image by shift_x and shift_y 00066 * Notice : Providing an interpolation kernel is optional. A sinc 00067 * kernel will be generated if none is provided. 00068 * To provide no kernel, pass (double*)NULL as last argument. 00069 *--------------------------------------------------------------------------*/ 00070 00071 OneImage * 00072 shift_image( 00073 OneImage * image_in, 00074 double shift_x, 00075 double shift_y, 00076 double * interp_kernel) ; 00077 00078 00079 /*--------------------------------------------------------------------------- 00080 * Function : shift_image_int() 00081 * In : OneImage, shift parameters in x and y 00082 * Out : OneImage 00083 * Job : Shifts an image by integer shift_x and shift_y 00084 * Notice : Fast because no interpolation is done 00085 *--------------------------------------------------------------------------*/ 00086 00087 OneImage * 00088 shift_image_int( 00089 OneImage * image_in, 00090 int shift_x, 00091 int shift_y 00092 ) ; 00093 00094 00095 00096 /*--------------------------------------------------------------------------- 00097 * Function : generate_interpolation_kernel() 00098 * Job : Computes tabulated values of the kernel 00099 * In : Kernel type 00100 * Out : Kernel values 00101 * Notice : kernel type is one of the following 00102 00103 "default" for default kernel, currently "tanh" 00104 "tanh" for hyperbolic tangent 00105 "sinc2" for square sinc 00106 "gauss" not implemented yet 00107 "lanczos" for Lanczos-based kernel 00108 "hamming" for Hamming kernel 00109 "hann" for Hann kernel 00110 *--------------------------------------------------------------------------*/ 00111 00112 /*<python>*/ 00113 double * 00114 generate_interpolation_kernel(const char * kernel_type) ; 00115 /*</python>*/ 00116 00117 00118 /*--------------------------------------------------------------------------- 00119 * Function : sinc() 00120 * In : double 00121 * Out : double 00122 * Job : cardinal sine 00123 * Notice : rescaled by PI 00124 *--------------------------------------------------------------------------*/ 00125 00126 double 00127 sinc(double x) ; 00128 00129 /*--------------------------------------------------------------------------- 00130 * Function : warp_image_linear() 00131 * In : 1 image, transformation parameters 00132 * Out : 1 image 00133 * Job : Warps an image according to a given (affine) transformation 00134 * Notice : 00135 *--------------------------------------------------------------------------*/ 00136 00137 OneImage * 00138 warp_image_linear( 00139 OneImage * image_in, 00140 double * param, 00141 char * kernel_type) ; 00142 00143 00144 /*--------------------------------------------------------------------------- 00145 * Function : warp_image_generic() 00146 * In : 1 image, transformation parameters 00147 * Out : 1 image 00148 * Job : Warps an image according to a given "generic" transformation 00149 * Use : Provide two poly2d definitions as in 'poly2d.h' 00150 * Notice : The output image will have the same size as the input image. 00151 *--------------------------------------------------------------------------*/ 00152 00153 OneImage * 00154 warp_image_generic( 00155 OneImage * image_in, 00156 char * kernel_type, 00157 poly2d * poly_u, 00158 poly2d * poly_v 00159 ) ; 00160 00161 00162 /*--------------------------------------------------------------------------- 00163 * Function : invert_linear_transform() 00164 * In : double pointer to 6 parameters 00165 * Out : Allocated double pointer to 6 parameters 00166 * Job : Invert an affine transform 00167 * Notice : 00168 *--------------------------------------------------------------------------*/ 00169 00170 /* 00171 * Given 6 parameters a, b, c, d, e, f defining an affine transform: 00172 * u = a.x + b.y + c 00173 * v = d.x + e.y + f 00174 * the inverse transform is also affine, and is defined by: 00175 * x = A.x + B.y + C 00176 * y = D.x + E.y + F 00177 * where: 00178 * det = (ae-bd) 00179 * A = e/det, B = -b/det, C = (bf-ce)/det 00180 * D = -d/det, E = a/det, F = (cd-af)/det 00181 */ 00182 00183 double * 00184 invert_linear_transform(double *trans) ; 00185 00186 00187 /*--------------------------------------------------------------------------- 00188 * Function : fast_warp_image() 00189 * In : 1 image, transformation parameters 00190 * Out : 1 image 00191 * Job : Warps an image according to a given (affine) transformation 00192 * Notice : Optimized version with unrolled loops, fast but... 00193 * unreadable. :) 00194 *--------------------------------------------------------------------------*/ 00195 00196 OneImage * 00197 fast_warp_image( 00198 OneImage * image_in, 00199 double * param, 00200 char * kernel_type) ; 00201 00202 00203 /*--------------------------------------------------------------------------- 00204 * Function : interpolate_poly3 00205 * In : position where value is wanted, number of points given, 00206 * array of x values, array of y values 00207 * Out : pointer to interpolated value, null pointer if failed 00208 * Job : uses least square minimisation to get poly. coefficients 00209 * computes the value of the fitted poly. at given position 00210 * to return interpolated value 00211 * Notice : 00212 *--------------------------------------------------------------------------*/ 00213 00214 pixelvalue * 00215 interpolate_poly3( 00216 pixelvalue x, 00217 int n_points, 00218 pixelvalue * Xarray, 00219 pixelvalue * Yarray) ; 00220 00221 00222 00223 /*--------------------------------------------------------------------------- 00224 Function : generate_tanh_kernel() 00225 In : double: steepness of the hyperbolic tangent 00226 Out : pointer to (samples) doubles 00227 Job : generate an hyperbolic tangent kernel 00228 Notice : don't touch 00229 ---------------------------------------------------------------------------*/ 00230 00231 00232 double * generate_tanh_kernel(double steep) ; 00233 00234 00235 /*--------------------------------------------------------------------------- 00236 Function : reverse_tanh_kernel() 00237 In : a tanh generated kernel in Fourier space 00238 Out : a reversed kernel in image space 00239 Job : transforms from Fourier to image space a tanh kernel 00240 Notice : optimized, only useful for generate_tanh_kernel() 00241 ---------------------------------------------------------------------------*/ 00242 00243 /* 00244 * Commented out in this header file. See source code for details 00245 00246 static void reverse_tanh_kernel(double * data, int nn) ; 00247 */ 00248 00249 00250 /*--------------------------------------------------------------------------- 00251 Function : show_interpolation_kernel() 00252 In : interpolation kernel name 00253 Out : a list of values for the requested kernel, on stdout 00254 Job : print out an interpolation kernel on stdout 00255 Notice : 00256 ---------------------------------------------------------------------------*/ 00257 00258 void show_interpolation_kernel(char * kernel_name) ; 00259 00260 00261 #endif 00262 /*--------------------------------------------------------------------------*/
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001