00001 #ifndef __FRESIZE_H 00002 #define __FRESIZE_H 00003 #include <complex.h> 00004 #include <fftw3.h> 00005 00006 struct fresize_struct { 00007 int method; 00008 int nsub; 00009 int hwidth; 00010 float *ker,*kerx,*kery; 00011 fftwf_complex *helpc,*fkernel,*fkernely; 00012 float *helpin,*helpout; 00013 fftwf_plan plan1,plan2,plan1y,plan2y; 00014 int nxin,nyin,nxinp,nyinp; 00015 }; 00016 00017 int init_fresize_sample( 00018 struct fresize_struct *pars, 00019 int nsub // Distance between sampled points 00020 ); 00021 00022 int init_fresize_bin( 00023 struct fresize_struct *pars, 00024 int nsub // Binsize 00025 ); 00026 00027 int init_fresize_boxcar( 00028 struct fresize_struct *pars, 00029 int hwidth, // Half width of boxcar. Full is 2*hwidth+1. 00030 int nsub // Distance between sampled points 00031 ); 00032 00033 int init_fresize_boxcar_fft( 00034 struct fresize_struct *pars, 00035 int hwidth, // Half width of boxcar. Full is 2*hwidth+1. 00036 int nsub, // Distance between sampled points 00037 int nxin, // Array size 00038 int nyin // Array size 00039 ); 00040 00041 int init_fresize_gaussian( // Simple square truncated Gaussian 00042 struct fresize_struct *pars, 00043 float sigma, // Shape is exp(-(d/sigma)^2/2) 00044 int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. 00045 int nsub // Distance between sampled points 00046 ); 00047 00048 int init_fresize_gaussian_fft( // Simple square truncated Gaussian. FFT version. 00049 struct fresize_struct *pars, 00050 float sigma, // Shape is exp(-(d/sigma)^2/2) 00051 int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. 00052 int nsub, // Distance between sampled points 00053 int nxin, // Array size 00054 int nyin // Array size 00055 ); 00056 00057 int init_fresize_sinc( // Sinc filter 00058 struct fresize_struct *pars, 00059 float wsinc, /* Shape is sinc(d/wsinc)*ap(d) 00060 wsinc is the amount by which the Nyquist is reduced. 00061 May want wsinc=nsub. */ 00062 int hwidth, // Half width of kernel. Full is 2*hwidth+1. 00063 int iap, /* Apodization method. Always ap=0 for d>nap*wsinc. 00064 iap=0 means no apodization ap=1 00065 iap=1 uses parabola ap=1-(d/(nap*wsinc))^2 00066 iap=2 uses sinc ap=sinc(d/(nap*wsinc)) 00067 all other cases give ap=1 (not guaranteed) */ 00068 int nap, /* Sinc apodization width in units of wsinc. 00069 Normally hwidth=nap*wsinc, 00070 but hwidth=nap*wsinc-1 works for integer */ 00071 int nsub // Distance between sampled points 00072 ); 00073 00074 int init_fresize_sinc_fft( // Sinc filter. FFT version. 00075 struct fresize_struct *pars, 00076 float wsinc, /* Shape is sinc(d/wsinc)*ap(d) 00077 wsinc is the amount by which the Nyquist is reduced. 00078 May want wsinc=nsub. */ 00079 int hwidth, // Half width of kernel. Full is 2*hwidth+1. 00080 int iap, /* Apodization method. Always ap=0 for d>nap*wsinc. 00081 iap=0 means no apodization ap=1 00082 iap=1 uses parabola ap=1-(d/(nap*wsinc))^2 00083 iap=2 uses sinc ap=sinc(d/(nap*wsinc)) 00084 all other cases give ap=1 (not guaranteed) */ 00085 int nap, /* Sinc apodization width in units of wsinc. 00086 Normally hwidth=nap*wsinc, 00087 but hwidth=nap*wsinc-1 works for integer */ 00088 int nsub, // Distance between sampled points 00089 int nxin, // Array size 00090 int nyin // Array size 00091 ); 00092 00093 int init_fresize_gaussian2( // Circularly truncated Gaussian 00094 struct fresize_struct *pars, 00095 float sigma, // Shape is exp(-(d/sigma)^2/2) 00096 float rmax, // Truncation radius. Probably rmax<=hwidth. 00097 int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. 00098 int nsub // Distance between sampled points 00099 ); 00100 00101 int init_fresize_gaussian2_fft( // Circularly truncated Gaussian. FFT version. 00102 struct fresize_struct *pars, 00103 float sigma, // Shape is exp(-(d/sigma)^2/2) 00104 float rmax, // Truncation radius. Probably rmax<=hwidth. 00105 int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. 00106 int nsub, // Distance between sampled points 00107 int nxin, // Input size 00108 int nyin // Input size 00109 ); 00110 00111 int init_fresize_airy( // 2D Airy filter 00112 struct fresize_struct *pars, 00113 float cdown, /* cdown is the amount by which the Nyquist is reduced. */ 00114 int hwidth, /* Half width of kernel. Full is 2*hwidth+1. 00115 Set to <0 to make routine set appropriate value */ 00116 int iap, /* Apodization method. Always ap=0 for d>Z_nap, where Z_nap os 00117 the position of the nap'th zero. 00118 iap=0 means no apodization ap=1 00119 iap=1 uses parabola ap=1-(d/Z_nap)^2 00120 iap=2 uses sinc ap=sinc(d/(Z_nap)) 00121 iap=3 uses Airy with first zero at Z_nap 00122 all other cases give ap=1 (not guaranteed) */ 00123 int nap, /* Apodizes to nap'th zero */ 00124 int nsub // Distance between sampled points 00125 ); 00126 00127 int init_fresize_airy_fft( // 2D Airy filter. FFT version. 00128 struct fresize_struct *pars, 00129 float cdown, /* cdown is the amount by which the Nyquist is reduced. */ 00130 int hwidth, /* Half width of kernel. Full is 2*hwidth+1. 00131 Set to <0 to make routine set appropriate value */ 00132 int iap, /* Apodization method. Always ap=0 for d>nap*cdown. 00133 iap=0 means no apodization ap=1 00134 iap=1 uses parabola ap=1-(d/(nap*cdown))^2 00135 iap=2 uses sinc ap=sinc(d/(nap*cdown)) 00136 iap=3 uses Airy with first zero at nap'th zero of main 00137 all other cases give ap=1 (not guaranteed) */ 00138 int nap, /* Apodizes to nap'th zero */ 00139 int nsub, // Distance between sampled points 00140 int nxin, // Input size 00141 int nyin // Input size 00142 ); 00143 00144 int init_fresize_user( 00145 struct fresize_struct *pars, 00146 int hwidth, // Half width of kernel. Full is 2*hwidth+1. 00147 int nsub, // Distance between sampled points 00148 float *user_ker // User specified kernel to convolve with. 00149 // Must be of size (2*hwidth+1) x (2*hwidth+1). 00150 // Kernel need not be and will not be normalized. 00151 ); 00152 00153 int free_fresize( 00154 struct fresize_struct *pars 00155 ); 00156 00157 int fresize( 00158 struct fresize_struct *pars, // Must have been initialized by init_fresize_XXX 00159 float *image_in, 00160 float *image_out, 00161 int nxin, // Size of input image 00162 int nyin, // Size of input image 00163 int nleadin, // Leading dimension of input image. nleadin>=nxin 00164 int nxout, // Size of xin, yin and image_out 00165 int nyout, // Size of xin, yin and image_out 00166 int nleadout, // Leading dimension. nlead>=nx 00167 int xoff, // Offset in x direction 00168 int yoff, // Offset in y direction 00169 float fillval // Value to use if outside area 00170 ); 00171 00172 int fsample( 00173 float *image_in, 00174 float *image_out, 00175 int nxin, 00176 int nyin, 00177 int nleadin, 00178 int nxout, 00179 int nyout, 00180 int nleadout, 00181 int nsub, 00182 int xoff, 00183 int yoff, 00184 float fillval 00185 ); 00186 00187 int fbin( 00188 float *image_in, 00189 float *image_out, 00190 int nxin, 00191 int nyin, 00192 int nleadin, 00193 int nxout, 00194 int nyout, 00195 int nleadout, 00196 int nsub, 00197 int xoff, 00198 int yoff, 00199 float fillval 00200 ); 00201 00202 #endif