Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | Friends | List of all members
Cylindrical_Wave_Decomposition Class Reference

#include <rotational_spectrum.h>

Collaboration diagram for Cylindrical_Wave_Decomposition:
Collaboration graph
[legend]

Public Member Functions

double interpolate (MultidimArray< double > &img, double y, double x)
 Interpolate image value (bilinear) More...
 
void compute_cwd (MultidimArray< double > &img)
 Compute the Cylindrical Wave decomposition of an image. More...
 

Public Attributes

int numin
 Minimum harmonics. More...
 
int numax
 Maximum harmonics. More...
 
double x0
 Center of symmetry (x) More...
 
double y0
 Center of symmetry (x) More...
 
double r1
 Minimum integration radius. More...
 
double r2
 Maximum integration radius. More...
 
double r3
 Integration increment. More...
 
int ir
 Ir. More...
 
MultidimArray< double > out_ampcos
 Ampcos. More...
 
MultidimArray< double > out_ampsin
 Ampsin. More...
 

Friends

std::ostream & operator<< (std::ostream &_out, const Cylindrical_Wave_Decomposition &_cwd)
 Show this object. More...
 

Detailed Description

Cylindrical_Wave_Decomposition class.

Definition at line 39 of file rotational_spectrum.h.

Member Function Documentation

◆ compute_cwd()

void Cylindrical_Wave_Decomposition::compute_cwd ( MultidimArray< double > &  img)

Compute the Cylindrical Wave decomposition of an image.

Definition at line 65 of file rotational_spectrum.cpp.

66 {
67  std::array<double,1281> coseno = {};
68  std::array<double,5191> ampcos = {};
69  std::array<double,5191> ampsen = {};
70 
71  double rh;
72  rh = XMIPP_MIN(r2, x0 - 4.);
73  rh = XMIPP_MIN(rh, y0 - 4.);
74  rh = XMIPP_MIN(rh, YSIZE(img) - x0 - 3.);
75  rh = XMIPP_MIN(rh, XSIZE(img) - y0 - 3.);
76  int ir_internal;
77  ir_internal = (int)((rh - r1) / r3 + 1);
78  int ind;
79  ind = 0;
80  int numin1;
81  int numax1;
82  numin1 = numin + 1;
83  numax1 = numax + 1;
84  int kk;
85  for (kk = numin1;kk <= numax1;kk++)
86  {
87  int k;
88  k = kk - 1;
89  double coefca;
90  double coefcb;
91  double coefsa;
92  double coefsb;
93  double h;
94  int ntot;
95  int my;
96  int my2;
97  int my4;
98  int my5;
99  int j;
100  if (k != 0)
101  {
102  my = (int)(1 + PI * rh / 2. / k);
103  my2 = 2 * my;
104  my4 = my * k;
105  my5 = my4 - 1;
106  ntot = 4 * my4;
107  h = 2. * PI / ntot;
108  double hdpi;
109  hdpi = h / PI;
110  double th;
111  th = k * h;
112  double ys;
113  ys = sin(th);
114  double zs;
115  zs = cos(th);
116  double ys2;
117  ys2 = sin(2. * th);
118  double b1;
119  b1 = 2. / (th * th) * (1. + zs * zs - ys2 / th);
120  double g1;
121  g1 = 4. / (th * th) * (ys / th - zs);
122  double d1;
123  d1 = 2. * th / 45.;
124  double e1;
125  e1 = d1 * ys * 2.;
126  d1 *= ys2;
127  coefca = (b1 + e1) * hdpi;
128  coefcb = (g1 - d1) * hdpi;
129  coefsa = (b1 - e1) * hdpi;
130  coefsb = (g1 + d1) * hdpi;
131  }
132  else
133  {
134  my = (int)(1 + PI * rh / 2.);
135  my2 = 2 * my;
136  my4 = my;
137  my5 = my4 - 1;
138  ntot = 4 * my4;
139  h = 2. * PI / ntot;
140  coefca = h / PI / 2.;
141  }
142  int i;
143  for (i = 1;i <= my5;i++)
144  {
145  double fi;
146  fi = i * h;
147  coseno[i] = sin(fi);
148  }
149  coseno[my4] = 1.;
150  int my3;
151  my3 = 2 * my4;
152  for (i = 1;i <= my5;i++)
153  {
154  coseno[my3-i] = coseno[i];
155  coseno[my3+i] = -coseno[i];
156  coseno[ntot-i] = -coseno[i];
157  coseno[ntot+i] = coseno[i];
158  }
159  coseno[my3] = 0.;
160  coseno[my3+my4] = -1.;
161  coseno[ntot] = 0.;
162  coseno[ntot+my4] = 1.;
163  double r11;
164  r11 = r1 - r3;
165  double ac;
166  double r;
167  for (int jr = 1;jr <= ir_internal;jr++)
168  {
169  ind++;
170  r = r11 + r3 * jr;
171  ac = 0.;
172  int i1c;
173  i1c = my4;
174  int i1s;
175  i1s = 0;
176  double x;
177  double y;
178  double z;
179  if (k != 0)
180  {
181  double as;
182  double bc;
183  double bs;
184  as = bc = bs = 0.;
185  for (i = 1;i <= k;i++)
186  {
187  int i2c;
188  i2c = my4;
189  int i2s;
190  i2s = 0;
191  for (j = 1;j <= my2;j++)
192  {
193  i1c++;
194  i1s++;
195  i2c += k;
196  i2s += k;
197  x = x0 + r * coseno[i1c];
198  y = y0 + r * coseno[i1s];
199  z = interpolate(img, y, x);
200  bc += z * coseno[i2c];
201  bs += z * coseno[i2s];
202  i1c++;
203  i1s++;
204  i2c += k;
205  i2s += k;
206  x = x0 + r * coseno[i1c];
207  y = y0 + r * coseno[i1s];
208  z = interpolate(img, y, x);
209  ac += z * coseno[i2c];
210  as += z * coseno[i2s];
211  }
212  }
213  ampcos[ind] = coefca * ac + coefcb * bc;
214  ampsen[ind] = coefsa * as + coefsb * bs;
215  }
216  else
217  for (j = 1;j <= ntot;j++)
218  {
219  i1c++;
220  i1s++;
221  x = x0 + r * coseno[i1c];
222  y = y0 + r * coseno[i1s];
223  z = interpolate(img, y, x);
224  ac += z;
225  ampcos[ind] = coefca * ac;
226  ampsen[ind] = 0.;
227  }
228  }
229  if (k == 0)
230  {
231  ac = 0.;
232  for (j = 1;j <= ir_internal;j++)
233  {
234  r = r11 + j * r3;
235  ac += ampcos[j] * 2. * PI * r;
236  }
237  ac /= (PI * (r * r - r1 * r1));
238  for (j = 1;j <= ir_internal;j++)
239  ampcos[j] -= ac;
240  }
241  }
242 
243  out_ampcos.initZeros((numax - numin + 1)*ir_internal);
246  {
247  A1D_ELEM(out_ampcos, i) = ampcos[i+1];
248  A1D_ELEM(out_ampsin, i) = ampsen[i+1];
249  }
250 }
#define YSIZE(v)
double x0
Center of symmetry (x)
MultidimArray< double > out_ampcos
Ampcos.
static double * y
double r2
Maximum integration radius.
double y0
Center of symmetry (x)
#define A1D_ELEM(v, i)
double r3
Integration increment.
doublereal * x
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
int ntot
float coseno[1281]
MultidimArray< double > out_ampsin
Ampsin.
#define XSIZE(v)
double interpolate(MultidimArray< double > &img, double y, double x)
Interpolate image value (bilinear)
float rh
double z
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void initZeros(const MultidimArray< T1 > &op)
#define PI
Definition: tools.h:43
double r1
Minimum integration radius.

◆ interpolate()

double Cylindrical_Wave_Decomposition::interpolate ( MultidimArray< double > &  img,
double  y,
double  x 
)

Interpolate image value (bilinear)

Definition at line 49 of file rotational_spectrum.cpp.

51 {
52  y = y - 1; // Since Fortran starts indexing at 1
53  x = x - 1;
54  auto iy = (int)y; /* Trunc the x, y coordinates to int */
55  auto ix = (int)x;
56  double scale = y - iy;
57  double *ptr_yx = &DIRECT_A2D_ELEM(img, iy, ix);
58  double *ptr_y1x = ptr_yx + XSIZE(img);
59  double introw1 = *ptr_yx + scale * (*(ptr_yx + 1) - *ptr_yx);
60  double introw2 = *ptr_y1x + scale * (*(ptr_y1x + 1) - *ptr_y1x);
61  return introw1 + (x - ix)*(introw2 - introw1);
62 }
static double * y
#define DIRECT_A2D_ELEM(v, i, j)
doublereal * x
#define XSIZE(v)

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  _out,
const Cylindrical_Wave_Decomposition _cwd 
)
friend

Show this object.

Definition at line 31 of file rotational_spectrum.cpp.

33 {
34  _out << "ir=" << _cwd.ir << std::endl
35  << "numin=" << _cwd.numin << std::endl
36  << "numax=" << _cwd.numax << std::endl
37  << "x0=" << _cwd.x0 << std::endl
38  << "y0=" << _cwd.y0 << std::endl
39  << "r1=" << _cwd.r1 << std::endl
40  << "r2=" << _cwd.r2 << std::endl
41  << "r3=" << _cwd.r3 << std::endl;
43  _out << _cwd.out_ampcos(i) << " "
44  << _cwd.out_ampsin(i) << std::endl;
45  return _out;
46 }
double x0
Center of symmetry (x)
MultidimArray< double > out_ampcos
Ampcos.
double r2
Maximum integration radius.
double y0
Center of symmetry (x)
double r3
Integration increment.
#define i
MultidimArray< double > out_ampsin
Ampsin.
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
double r1
Minimum integration radius.

Member Data Documentation

◆ ir

int Cylindrical_Wave_Decomposition::ir

Ir.

Definition at line 64 of file rotational_spectrum.h.

◆ numax

int Cylindrical_Wave_Decomposition::numax

Maximum harmonics.

Definition at line 46 of file rotational_spectrum.h.

◆ numin

int Cylindrical_Wave_Decomposition::numin

Minimum harmonics.

Definition at line 43 of file rotational_spectrum.h.

◆ out_ampcos

MultidimArray< double > Cylindrical_Wave_Decomposition::out_ampcos

Ampcos.

Definition at line 67 of file rotational_spectrum.h.

◆ out_ampsin

MultidimArray< double > Cylindrical_Wave_Decomposition::out_ampsin

Ampsin.

Definition at line 70 of file rotational_spectrum.h.

◆ r1

double Cylindrical_Wave_Decomposition::r1

Minimum integration radius.

Definition at line 55 of file rotational_spectrum.h.

◆ r2

double Cylindrical_Wave_Decomposition::r2

Maximum integration radius.

Definition at line 58 of file rotational_spectrum.h.

◆ r3

double Cylindrical_Wave_Decomposition::r3

Integration increment.

Definition at line 61 of file rotational_spectrum.h.

◆ x0

double Cylindrical_Wave_Decomposition::x0

Center of symmetry (x)

Definition at line 49 of file rotational_spectrum.h.

◆ y0

double Cylindrical_Wave_Decomposition::y0

Center of symmetry (x)

Definition at line 52 of file rotational_spectrum.h.


The documentation for this class was generated from the following files: