1 |
#ifndef __FRESIZE_H |
2 |
#define __FRESIZE_H |
3 |
#include <complex.h> |
4 |
#include <fftw3.h> |
5 |
|
6 |
struct fresize_struct { |
7 |
int method; |
8 |
int nsub; |
9 |
int hwidth; |
10 |
float *ker,*kerx,*kery; |
11 |
fftwf_complex *helpc,*fkernel,*fkernely; |
12 |
float *helpin,*helpout; |
13 |
fftwf_plan plan1,plan2,plan1y,plan2y; |
14 |
int nxin,nyin,nxinp,nyinp; |
15 |
}; |
16 |
|
17 |
int init_fresize_sample( |
18 |
struct fresize_struct *pars, |
19 |
int nsub // Distance between sampled points |
20 |
); |
21 |
|
22 |
int init_fresize_bin( |
23 |
struct fresize_struct *pars, |
24 |
int nsub // Binsize |
25 |
); |
26 |
|
27 |
int init_fresize_boxcar( |
28 |
struct fresize_struct *pars, |
29 |
int hwidth, // Half width of boxcar. Full is 2*hwidth+1. |
30 |
int nsub // Distance between sampled points |
31 |
); |
32 |
|
33 |
int init_fresize_boxcar_fft( |
34 |
struct fresize_struct *pars, |
35 |
int hwidth, // Half width of boxcar. Full is 2*hwidth+1. |
36 |
int nsub, // Distance between sampled points |
37 |
int nxin, // Array size |
38 |
int nyin // Array size |
39 |
); |
40 |
|
41 |
int init_fresize_gaussian( // Simple square truncated Gaussian |
42 |
struct fresize_struct *pars, |
43 |
float sigma, // Shape is exp(-(d/sigma)^2/2) |
44 |
int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. |
45 |
int nsub // Distance between sampled points |
46 |
); |
47 |
|
48 |
int init_fresize_gaussian_fft( // Simple square truncated Gaussian. FFT version. |
49 |
struct fresize_struct *pars, |
50 |
float sigma, // Shape is exp(-(d/sigma)^2/2) |
51 |
int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. |
52 |
int nsub, // Distance between sampled points |
53 |
int nxin, // Array size |
54 |
int nyin // Array size |
55 |
); |
56 |
|
57 |
int init_fresize_sinc( // Sinc filter |
58 |
struct fresize_struct *pars, |
59 |
float wsinc, /* Shape is sinc(d/wsinc)*ap(d) |
60 |
wsinc is the amount by which the Nyquist is reduced. |
61 |
May want wsinc=nsub. */ |
62 |
int hwidth, // Half width of kernel. Full is 2*hwidth+1. |
63 |
int iap, /* Apodization method. Always ap=0 for d>nap*wsinc. |
64 |
iap=0 means no apodization ap=1 |
65 |
iap=1 uses parabola ap=1-(d/(nap*wsinc))^2 |
66 |
iap=2 uses sinc ap=sinc(d/(nap*wsinc)) |
67 |
all other cases give ap=1 (not guaranteed) */ |
68 |
int nap, /* Sinc apodization width in units of wsinc. |
69 |
Normally hwidth=nap*wsinc, |
70 |
but hwidth=nap*wsinc-1 works for integer */ |
71 |
int nsub // Distance between sampled points |
72 |
); |
73 |
|
74 |
int init_fresize_sinc_fft( // Sinc filter. FFT version. |
75 |
struct fresize_struct *pars, |
76 |
float wsinc, /* Shape is sinc(d/wsinc)*ap(d) |
77 |
wsinc is the amount by which the Nyquist is reduced. |
78 |
May want wsinc=nsub. */ |
79 |
int hwidth, // Half width of kernel. Full is 2*hwidth+1. |
80 |
int iap, /* Apodization method. Always ap=0 for d>nap*wsinc. |
81 |
iap=0 means no apodization ap=1 |
82 |
iap=1 uses parabola ap=1-(d/(nap*wsinc))^2 |
83 |
iap=2 uses sinc ap=sinc(d/(nap*wsinc)) |
84 |
all other cases give ap=1 (not guaranteed) */ |
85 |
int nap, /* Sinc apodization width in units of wsinc. |
86 |
Normally hwidth=nap*wsinc, |
87 |
but hwidth=nap*wsinc-1 works for integer */ |
88 |
int nsub, // Distance between sampled points |
89 |
int nxin, // Array size |
90 |
int nyin // Array size |
91 |
); |
92 |
|
93 |
int init_fresize_gaussian2( // Circularly truncated Gaussian |
94 |
struct fresize_struct *pars, |
95 |
float sigma, // Shape is exp(-(d/sigma)^2/2) |
96 |
float rmax, // Truncation radius. Probably rmax<=hwidth. |
97 |
int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. |
98 |
int nsub // Distance between sampled points |
99 |
); |
100 |
|
101 |
int init_fresize_gaussian2_fft( // Circularly truncated Gaussian. FFT version. |
102 |
struct fresize_struct *pars, |
103 |
float sigma, // Shape is exp(-(d/sigma)^2/2) |
104 |
float rmax, // Truncation radius. Probably rmax<=hwidth. |
105 |
int hwidth, // Half (truncation) width of kernel. Full is 2*hwidth+1. |
106 |
int nsub, // Distance between sampled points |
107 |
int nxin, // Input size |
108 |
int nyin // Input size |
109 |
); |
110 |
|
111 |
int init_fresize_airy( // 2D Airy filter |
112 |
struct fresize_struct *pars, |
113 |
float cdown, /* cdown is the amount by which the Nyquist is reduced. */ |
114 |
int hwidth, /* Half width of kernel. Full is 2*hwidth+1. |
115 |
Set to <0 to make routine set appropriate value */ |
116 |
int iap, /* Apodization method. Always ap=0 for d>Z_nap, where Z_nap os |
117 |
the position of the nap'th zero. |
118 |
iap=0 means no apodization ap=1 |
119 |
iap=1 uses parabola ap=1-(d/Z_nap)^2 |
120 |
iap=2 uses sinc ap=sinc(d/(Z_nap)) |
121 |
iap=3 uses Airy with first zero at Z_nap |
122 |
all other cases give ap=1 (not guaranteed) */ |
123 |
int nap, /* Apodizes to nap'th zero */ |
124 |
int nsub // Distance between sampled points |
125 |
); |
126 |
|
127 |
int init_fresize_airy_fft( // 2D Airy filter. FFT version. |
128 |
struct fresize_struct *pars, |
129 |
float cdown, /* cdown is the amount by which the Nyquist is reduced. */ |
130 |
int hwidth, /* Half width of kernel. Full is 2*hwidth+1. |
131 |
Set to <0 to make routine set appropriate value */ |
132 |
int iap, /* Apodization method. Always ap=0 for d>nap*cdown. |
133 |
iap=0 means no apodization ap=1 |
134 |
iap=1 uses parabola ap=1-(d/(nap*cdown))^2 |
135 |
iap=2 uses sinc ap=sinc(d/(nap*cdown)) |
136 |
iap=3 uses Airy with first zero at nap'th zero of main |
137 |
all other cases give ap=1 (not guaranteed) */ |
138 |
int nap, /* Apodizes to nap'th zero */ |
139 |
int nsub, // Distance between sampled points |
140 |
int nxin, // Input size |
141 |
int nyin // Input size |
142 |
); |
143 |
|
144 |
int init_fresize_user( |
145 |
struct fresize_struct *pars, |
146 |
int hwidth, // Half width of kernel. Full is 2*hwidth+1. |
147 |
int nsub, // Distance between sampled points |
148 |
float *user_ker // User specified kernel to convolve with. |
149 |
// Must be of size (2*hwidth+1) x (2*hwidth+1). |
150 |
// Kernel need not be and will not be normalized. |
151 |
); |
152 |
|
153 |
int free_fresize( |
154 |
struct fresize_struct *pars |
155 |
); |
156 |
|
157 |
int fresize( |
158 |
struct fresize_struct *pars, // Must have been initialized by init_fresize_XXX |
159 |
float *image_in, |
160 |
float *image_out, |
161 |
int nxin, // Size of input image |
162 |
int nyin, // Size of input image |
163 |
int nleadin, // Leading dimension of input image. nleadin>=nxin |
164 |
int nxout, // Size of xin, yin and image_out |
165 |
int nyout, // Size of xin, yin and image_out |
166 |
int nleadout, // Leading dimension. nlead>=nx |
167 |
int xoff, // Offset in x direction |
168 |
int yoff, // Offset in y direction |
169 |
float fillval // Value to use if outside area |
170 |
); |
171 |
|
172 |
int fsample( |
173 |
float *image_in, |
174 |
float *image_out, |
175 |
int nxin, |
176 |
int nyin, |
177 |
int nleadin, |
178 |
int nxout, |
179 |
int nyout, |
180 |
int nleadout, |
181 |
int nsub, |
182 |
int xoff, |
183 |
int yoff, |
184 |
float fillval |
185 |
); |
186 |
|
187 |
int fbin( |
188 |
float *image_in, |
189 |
float *image_out, |
190 |
int nxin, |
191 |
int nyin, |
192 |
int nleadin, |
193 |
int nxout, |
194 |
int nyout, |
195 |
int nleadout, |
196 |
int nsub, |
197 |
int xoff, |
198 |
int yoff, |
199 |
float fillval |
200 |
); |
201 |
|
202 |
#endif |