24 int i, j, ik, width_2;
25 double s1, s2, c, arg, arg1, arg2, iwidth, piwidth, incr;
29 if ( power < 0 ) width = 1;
30 else width = kernel_width;
32 half_width = width_2 = (width - 1) / 2;
34 size = (ndiv + 1) * width;
35 data =
new float[size];
37 for ( i = 0; i < size; i++ ) data[i] = 0;
40 for ( i = 0; i < size; i++ ) data[i] = 1;
42 iwidth = 1.0L / width;
43 piwidth =
M_PI * iwidth;
47 for ( i = 1, ik = width; i < ndiv; i++ ) {
48 arg1 =
M_PI * (arg + width_2);
49 s1 = iwidth *
bsin (arg1);
51 for ( j = 0; j < width; j++, ik++ ) {
54 data[ik] = (s1 / s2) * pow (c, power);
65 cout <<
"Kernel parameters:" << endl;
66 cout <<
"Width: " << width << endl;
67 cout <<
"Half width: " << half_width << endl;
68 cout <<
"Power: " << power << endl;
69 cout <<
"Divisions: " << ndiv << endl;
70 cout <<
"Data size: " << size << endl << endl;
74 cout <<
"Kernel content:" << endl;
75 for ( i=ik=0; i<=ndiv; i++ ) {
77 for ( j=0; j<width; j++, ik++ ) {
78 cout <<
tab << data[ik];
102 long x, y, z, kx, ky, kz, mx, my, mz, jx, jy, jz, nx, ny, nz;
103 long ix = (long) floor(m.
x());
104 long iy = (long) floor(m.
y());
105 long iz = (long) floor(m.
z());
106 long ikx = half_width;
107 long iky = half_width;
108 long ikz = half_width;
111 nx = ny = nz = width;
113 if ( p->
sizeX() > 1 ) {
114 ikx = ((long) ((m.
x() - ix)*ndiv + 0.5))*width;
118 if ( p->
sizeY() > 1 ) {
119 iky = ((long) ((m.
y() - iy)*ndiv + 0.5))*width;
123 if ( p->
sizeZ() > 1 ) {
124 ikz = ((long) ((m.
z() - iz)*ndiv + 0.5))*width;
128 for ( z=0, kz=ikz, mz=iz; z<nz; z++, kz++, mz++ ) {
130 while ( jz < 0 ) jz += p->
sizeZ();
133 for ( y=0, ky=iky, my=iy; y<ny; y++, ky++, my++ ) {
135 while ( jy < 0 ) jy += p->
sizeY();
137 jy = (jz + jy)*p->
sizeX();
138 wyz = data[ky]*data[kz];
139 for ( x=0, kx=ikx, mx=ix; x<nx; x++, kx++, mx++ ) {
141 while ( jx < 0 ) jx += p->
sizeX();
143 value += p->
complex(jy + jx) * (data[kx]*wyz);
149 cerr <<
"Warning: Interpolated complex value not finite! (" << value <<
")" << endl;
double bcos(double x)
Avoid non-zero values for cos(PI/2) and cos(-PI/2).
Header file for general utilities.
Header file for filter kernel functions.
CompoundType compound_type()
double bsin(double x)
Avoid non-zero values for sin(PI) and sin(-PI).
General image parameter class.
Complex< double > interpolate(Bimage *p, unsigned long img_num, Vector3< float > m)
Calculates the complex value at an image location by kernel-based interpolation.
Complex< double > complex(size_t j)
Returns a complex value at the given index.
Header file for trigonometry functions.
ostream & tab(ostream &out)