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