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

#include <rotational_spectrum.h>

Collaboration diagram for Rotational_Spectrum:
Collaboration graph
[legend]

Public Member Functions

void compute_rotational_spectrum (MultidimArray< double > &img, double xr1, double xr2, double xdr, double xr)
 
void compute_rotational_spectrum (Cylindrical_Wave_Decomposition &cwd, double xr1, double xr2, double xdr, double xr)
 Compute rotational spectrum using CWD. More...
 

Public Attributes

int ir
 
int numin
 Minimum harmonics. More...
 
int numax
 Maximum harmonics. More...
 
double x0
 Center of symmetry (x). More...
 
double y0
 Center of symmetry (y). More...
 
double rl
 Minimum integration radius. More...
 
double rh
 Maximum integration radius. More...
 
double dr
 Integration increment. More...
 
MultidimArray< double > rot_spectrum
 Rotational spectrum. More...
 

Friends

std::ostream & operator<< (std::ostream &_out, const Rotational_Spectrum &_spt)
 Show. More...
 

Detailed Description

Rotational spectrum.

Example of use:

int main(int argc, char** argv)
{
ImageXmipp I(argv[1]);
int rl = 0;
int rh = 22;
int dr = 1;
spt.rl = rl;
spt.rh = rh;
spt.dr = dr;
spt.numin = 1;
spt.numax = 15;
spt.x0 = (double) XSIZE(I()) / 2;
spt.y0 = (double) YSIZE(I()) / 2;
spt.compute_rotational_spectrum (I(), rl, rh, dr, rh - rl);
std::cout << spt.rot_spectrum << std::endl;
return 0;
}

Definition at line 114 of file rotational_spectrum.h.

Member Function Documentation

◆ compute_rotational_spectrum() [1/2]

void Rotational_Spectrum::compute_rotational_spectrum ( MultidimArray< double > &  img,
double  xr1,
double  xr2,
double  xdr,
double  xr 
)

Compute rotational spectrum of an image.

xr1 is the minimum integration radius. xr2 the maximum integration radius. xdr the increment, and xr the length of integration. Usually, xr=xr2-xr1.

Definition at line 403 of file rotational_spectrum.cpp.

405 {
406  // Compute the cylindrical wave decomposition
408  cwd.numin = numin;
409  cwd.numax = numax;
410  cwd.x0 = (x0 == -1) ? (double)XSIZE(img) / 2 : x0;
411  cwd.y0 = (y0 == -1) ? (double)YSIZE(img) / 2 : y0;
412  cwd.r1 = rl;
413  cwd.r2 = rh;
414  cwd.r3 = dr;
415  cwd.compute_cwd(img);
416  ir = cwd.ir;
417 
418  // Compute the rotational spectrum
419  compute_rotational_spectrum(cwd, xr1, xr2, xdr, xr);
420 }
int numax
Maximum harmonics.
double rh
Maximum integration radius.
#define YSIZE(v)
double x0
Center of symmetry (x)
double r2
Maximum integration radius.
double y0
Center of symmetry (x)
double r3
Integration increment.
#define XSIZE(v)
void compute_cwd(MultidimArray< double > &img)
Compute the Cylindrical Wave decomposition of an image.
int numin
Minimum harmonics.
double y0
Center of symmetry (y).
double dr
Integration increment.
double x0
Center of symmetry (x).
void compute_rotational_spectrum(MultidimArray< double > &img, double xr1, double xr2, double xdr, double xr)
double r1
Minimum integration radius.
double rl
Minimum integration radius.

◆ compute_rotational_spectrum() [2/2]

void Rotational_Spectrum::compute_rotational_spectrum ( Cylindrical_Wave_Decomposition cwd,
double  xr1,
double  xr2,
double  xdr,
double  xr 
)

Compute rotational spectrum using CWD.

Definition at line 267 of file rotational_spectrum.cpp.

270 {
271  double *e[MAX_HARMONIC];
272  double *ep[MAX_HARMONIC];
273  double *erp [MAX_HARMONIC];
274 
275  // Read the information from the Cylindrical Wave Decomposition .........
276  auto c = (double *) calloc(5191, sizeof(double));
277  auto s = (double *) calloc(5191, sizeof(double));
278  if ((NULL == c) || (NULL == s))
279  REPORT_ERROR(ERR_MEM_NOTENOUGH, "compute_rotational_spectrum::no memory");
280 
281  int numin = cwd.numin;
282  int numax = cwd.numax;
283  double rl = cwd.r1;
284  double rh = cwd.r2;
285  double dr = cwd.r3;
287  {
288  c[i+1] = A1D_ELEM(cwd.out_ampcos, i);
289  s[i+1] = A1D_ELEM(cwd.out_ampsin, i);
290  }
291 
292  int n = numax - numin + 1;
293  auto m = (int)((rh - rl) / dr + 1);
294  for (int i = 1; i <= n; i++) {
295  e[i] = (double *) calloc(m + 1, sizeof(double));
296  if (NULL == e[i])
297  REPORT_ERROR(ERR_MEM_NOTENOUGH, "compute_rotational_spectrum::no memory");
298  }
299  auto rv = (double *) calloc(m + 1, sizeof(double));
300  auto st = (double *) calloc(m + 1, sizeof(double));
301  if ((NULL == rv) || (NULL == st))
302  REPORT_ERROR(ERR_MEM_NOTENOUGH, "compute_rotational_spectrum::no memory");
303 
304  // Computations .........................................................
305  int j1 = 0;
306  if (numin == 0)
307  j1 = 2;
308  else
309  j1 = 1;
310  int k = 0;
311  for (int i = 1; i <= n; i++)
312  for (int j = 1; j <= m; j++)
313  {
314  k++;
315  e[i][j] = c[k] * c[k] + s[k] * s[k];
316  }
317 
318  for (int i = 1; i <= m; i++)
319  {
320  rv[i] = rl + dr * (i - 1);
321  st[i] = 0;
322  for (int j = j1; j <= n; j++)
323  st[i] += e[j][i];
324  }
325 
326  auto ir1 = (int)((xr1 - rl) / dr + 1);
327  if (ir1 < 1)
328  ir1 = 1;
329  auto ir2 = (int)((XMIPP_MIN(xr2, rh) - rl) / dr + 1);
330  if (ir2 < ir1)
331  ir2 = ir1;
332  auto ndr = (int)(xdr / dr);
333  if (ndr < 1)
334  ndr = 1;
335  int nr = 0;
336  if (xr < 0)
337  nr = m;
338  else
339  nr = (int)(xr / dr + 1);
340  ir2 = XMIPP_MIN(ir2, m);
341  int ncol = ir2 - nr + 1 - ir1;
342  if (ncol < 0)
343  ncol = 0;
344  else
345  ncol = 1 + ncol / ndr;
346  if (ncol == 0)
347  REPORT_ERROR(ERR_VALUE_INCORRECT, "compute_rotational_spectrum::Incorrect data");
348 
349  int nvez = (ncol - 1) / 13 + 1;
350  for (int i = 1; i <= n; i++) {
351  ep[i] = (double *) calloc(ncol + 1, sizeof(double));
352  erp[i] = (double *) calloc(ncol + 1, sizeof(double));
353  if ((NULL == ep[i]) || (NULL == erp[i]))
354  REPORT_ERROR(ERR_MEM_NOTENOUGH, "compute_rotational_spectrum::no memory");
355  }
356  auto rp1 = (double *) calloc(ncol + 1, sizeof(double));
357  auto rp2 = (double *) calloc(ncol + 1, sizeof(double));
358  auto sp = (double *) calloc(ncol + 1, sizeof(double));
359  if ((NULL == rp1) || (NULL == rp2) || (NULL == sp))
360  REPORT_ERROR(ERR_MEM_NOTENOUGH, "compute_rotational_spectrum::no memory");
361  for (k = 1; k <= ncol; k++)
362  {
363  int irk = ir1 + (k - 1) * ndr - 1;
364  rp1[k] = 10 * rv[irk+1];
365  rp2[k] = 10 * rv[irk+nr];
366  sp[k] = 0;
367  for (int k1 = 1; k1 <= nr; k1++)
368  sp[k] += st[irk+k1];
369  for (int i = 1; i <= n; i++)
370  {
371  ep[i][k] = 0;
372  for (int k1 = 1; k1 <= nr; k1 ++)
373  ep [i][k] += e[i][irk+k1];
374  erp[i][k] = 1000000. * ep[i][k] / sp[k];
375  }
376  }
377 
378  // Keep results .........................................................
379  rot_spectrum.initZeros(n - j1 + 1);
380  for (k = 1; k <= nvez; k++)
381  {
382  int k1 = 13 * (k - 1) + 1;
383  for (int i = j1; i <= n; i++)
384  rot_spectrum(i - j1) = erp[i][k1] / 10000;
385  }
386 
387  // Free memory
388  for (int i = 1; i <= n; i++)
389  {
390  free(ep[i]);
391  free(erp [i]);
392  }
393  free(c);
394  free(s);
395  free(rv);
396  free(st);
397  free(rp1);
398  free(rp2);
399  free(sp);
400 }
int numax
Maximum harmonics.
double rh
Maximum integration radius.
MultidimArray< double > out_ampcos
Ampcos.
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
doublereal * c
double r2
Maximum integration radius.
MultidimArray< double > rot_spectrum
Rotational spectrum.
There is not enough memory for allocation.
Definition: xmipp_error.h:166
#define A1D_ELEM(v, i)
double r3
Integration increment.
#define MAX_HARMONIC
#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
MultidimArray< double > out_ampsin
Ampsin.
free((char *) ob)
int numin
Minimum harmonics.
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
#define j
int m
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
double dr
Integration increment.
void initZeros(const MultidimArray< T1 > &op)
Incorrect value received.
Definition: xmipp_error.h:195
double r1
Minimum integration radius.
int * n
double rl
Minimum integration radius.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  _out,
const Rotational_Spectrum _spt 
)
friend

Show.

Definition at line 253 of file rotational_spectrum.cpp.

254 {
255  _out << "numin=" << _spt.numin << std::endl
256  << "numax=" << _spt.numax << std::endl
257  << "x0=" << _spt.x0 << std::endl
258  << "y0=" << _spt.y0 << std::endl
259  << "rl=" << _spt.rl << std::endl
260  << "rh=" << _spt.rh << std::endl
261  << "dr=" << _spt.dr << std::endl;
262  return _out;
263 }
int numax
Maximum harmonics.
double rh
Maximum integration radius.
int numin
Minimum harmonics.
double y0
Center of symmetry (y).
double dr
Integration increment.
double x0
Center of symmetry (x).
double rl
Minimum integration radius.

Member Data Documentation

◆ dr

double Rotational_Spectrum::dr

Integration increment.

Definition at line 144 of file rotational_spectrum.h.

◆ ir

int Rotational_Spectrum::ir

Ir.

This value is given by the Cylindrical Wave Decomposition. It is not necessary to fill this field if the rotational spectrum is computed on an image.

Definition at line 123 of file rotational_spectrum.h.

◆ numax

int Rotational_Spectrum::numax

Maximum harmonics.

Definition at line 129 of file rotational_spectrum.h.

◆ numin

int Rotational_Spectrum::numin

Minimum harmonics.

Definition at line 126 of file rotational_spectrum.h.

◆ rh

double Rotational_Spectrum::rh

Maximum integration radius.

Definition at line 141 of file rotational_spectrum.h.

◆ rl

double Rotational_Spectrum::rl

Minimum integration radius.

Definition at line 138 of file rotational_spectrum.h.

◆ rot_spectrum

MultidimArray< double > Rotational_Spectrum::rot_spectrum

Rotational spectrum.

Definition at line 147 of file rotational_spectrum.h.

◆ x0

double Rotational_Spectrum::x0

Center of symmetry (x).

Definition at line 132 of file rotational_spectrum.h.

◆ y0

double Rotational_Spectrum::y0

Center of symmetry (y).

Definition at line 135 of file rotational_spectrum.h.


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