Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Polar< T > Class Template Reference

#include <polar.h>

Collaboration diagram for Polar< T >:
Collaboration graph
[legend]

Public Member Functions

 Polar ()
 
 Polar (const Polar &P)
 
 ~Polar ()
 
Polaroperator= (const Polar &P)
 
Polaroperator- (const T val) const
 
Polaroperator+ (const T val)
 
Polaroperator* (const T val)
 
Polaroperator/ (const T val)
 
void operator-= (const T val)
 
void operator+= (const T val)
 
void operator*= (const T val)
 
void operator/= (const T val)
 
Polaroperator-= (const Polar< T > in)
 
Polaroperator+= (const Polar< T > in)
 
Polaroperator*= (const Polar< T > in)
 
Polaroperator/= (const Polar< T > in)
 
void rename (const FileName &newName)
 
void clear ()
 
const FileNamename () const
 
int getRingNo () const
 
int getMode () const
 
double getOversample () const
 
int getSampleNo (int iring) const
 
int getSampleNoOuterRing () const
 
double getRadius (int iring) const
 
MultidimArray< T > & getRing (int i)
 
const MultidimArray< T > & getRing (int i) const
 
void setRing (int i, MultidimArray< T > val)
 
T & getPixel (int r, int f) const
 
T & operator() (int r, int f) const
 
void setPixel (int r, int f, T val) const
 
void computeAverageAndStddev (double &avg, double &stddev, int mode=FULL_CIRCLES) const
 
void normalize (double average, double stddev)
 
void getCartesianCoordinates (std::vector< double > &x, std::vector< double > &y, std::vector< T > &data, const int extra_shell=GRIDDING_K/2)
 
void getPolarFromCartesianBSpline (const MultidimArray< T > &M1, int first_ring, int last_ring, int BsplineOrder=3, double xoff=0., double yoff=0., double oversample1=1., int mode1=FULL_CIRCLES)
 
void calculateFftwPlans (Polar_fftw_plans &out)
 

Public Attributes

int mode
 
double oversample
 
std::vector< double > ring_radius
 
std::vector< MultidimArray< T > > rings
 

Protected Attributes

FileName fn_pol
 

Detailed Description

template<typename T>
class Polar< T >

Class for polar coodinates

Definition at line 67 of file polar.h.

Constructor & Destructor Documentation

◆ Polar() [1/2]

template<typename T>
Polar< T >::Polar ( )
inline

Empty constructor

An empty image with size 0x0 is created.

Definition at line 85 of file polar.h.

86  {
87  fn_pol = "";
88  ring_radius.clear();
89  rings.clear();
91  oversample = 1.;
92  }
FileName fn_pol
Definition: polar.h:70
double oversample
Definition: polar.h:73
constexpr int FULL_CIRCLES
Definition: polar.h:40
std::vector< double > ring_radius
Definition: polar.h:74
int mode
Definition: polar.h:72
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ Polar() [2/2]

template<typename T>
Polar< T >::Polar ( const Polar< T > &  P)
inline

Copy constructor

Polar P2(P1);

Definition at line 100 of file polar.h.

101  {
102  rings = P.rings;
103  fn_pol = P.fn_pol;
105  mode = P.mode;
107  }
FileName fn_pol
Definition: polar.h:70
double oversample
Definition: polar.h:73
std::vector< double > ring_radius
Definition: polar.h:74
int mode
Definition: polar.h:72
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ ~Polar()

template<typename T>
Polar< T >::~Polar ( )
inline

Destructor.

Definition at line 111 of file polar.h.

112  {
113  rings.clear();
114  ring_radius.clear();
115  }
std::vector< double > ring_radius
Definition: polar.h:74
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

Member Function Documentation

◆ calculateFftwPlans()

template<typename T>
void Polar< T >::calculateFftwPlans ( Polar_fftw_plans out)
inline

Precalculate a vector with FFTW plans for all rings

Definition at line 708 of file polar.h.

709  {
710  (out.arrays).resize(rings.size());
711  for (size_t iring = 0; iring < rings.size(); iring++)
712  {
713  (out.arrays)[iring] = rings[iring];
714  auto *ptr_transformer = new FourierTransformer();
715  ptr_transformer->setReal((out.arrays)[iring]);
716  out.transformers.push_back(ptr_transformer);
717  }
718  }
std::vector< FourierTransformer * > transformers
Definition: polar.h:55
std::vector< MultidimArray< T > > rings
Definition: polar.h:75
std::vector< MultidimArray< double > > arrays
Definition: polar.h:56

◆ clear()

template<typename T>
void Polar< T >::clear ( )
inline

Empty polar

This function clears the polar to an empty vector without name.

P.clear();

Definition at line 295 of file polar.h.

296  {
297  fn_pol = "";
298  rings.clear();
299  ring_radius.clear();
300  mode = FULL_CIRCLES;
301  oversample = 1.;
302  }
FileName fn_pol
Definition: polar.h:70
double oversample
Definition: polar.h:73
constexpr int FULL_CIRCLES
Definition: polar.h:40
std::vector< double > ring_radius
Definition: polar.h:74
int mode
Definition: polar.h:72
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ computeAverageAndStddev()

template<typename T>
void Polar< T >::computeAverageAndStddev ( double &  avg,
double &  stddev,
int  mode = FULL_CIRCLES 
) const
inline

Compute sum or average of all pixels in polar rings.

Definition at line 488 of file polar.h.

490  {
491  double aux;
492  double sum = 0.;
493  double sum2=0.;
494  double twopi;
495  double w;
496  double N = 0;
497 
498  if (mode == FULL_CIRCLES)
499  twopi = 2.*PI;
500  else if (mode == HALF_CIRCLES)
501  twopi = PI;
502  else
503  REPORT_ERROR(ERR_VALUE_INCORRECT,"Incorrect mode for computeAverageAndStddev");
504 
505  size_t imax=rings.size();
506  const double *ptrRing_radius=&ring_radius[0];
507  for (size_t i = 0; i < imax; ++i, ++ptrRing_radius)
508  {
509  // take varying sampling into account
510  w = (twopi * (*ptrRing_radius)) / (double) XSIZE(rings[i]);
511  const MultidimArray<T> &rings_i=rings[i];
512  for (size_t j = 0; j < XSIZE(rings_i); j++)
513  {
514  aux = DIRECT_A1D_ELEM(rings_i,j);
515  double waux=w*aux;
516  sum += waux;
517  sum2 += waux * aux;
518  N += w;
519  }
520  }
521  if (N>0)
522  {
523  sum2 = sum2 / N;
524  avg = sum / N;
525  stddev=sqrt(fabs(sum2-avg*avg));
526  }
527  else if (N != 0.)
528  {
529  avg = sum;
530  stddev=sqrt(fabs(sum2-avg*avg));
531  }
532  else
533  stddev=avg=0;
534  }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void sqrt(Image< double > &op)
doublereal * w
#define i
constexpr int FULL_CIRCLES
Definition: polar.h:40
#define DIRECT_A1D_ELEM(v, i)
std::vector< double > ring_radius
Definition: polar.h:74
#define XSIZE(v)
constexpr int HALF_CIRCLES
Definition: polar.h:41
int mode
Definition: polar.h:72
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75
#define PI
Definition: tools.h:43
Incorrect value received.
Definition: xmipp_error.h:195

◆ getCartesianCoordinates()

template<typename T>
void Polar< T >::getCartesianCoordinates ( std::vector< double > &  x,
std::vector< double > &  y,
std::vector< T > &  data,
const int  extra_shell = GRIDDING_K/2 
)
inline

Definition at line 559 of file polar.h.

563  {
564  // Only for full circles for now!
565  if (mode != FULL_CIRCLES)
566  REPORT_ERROR(ERR_VALUE_INCORRECT,"VoronoiArea only implemented for FULL_CIRCLES mode of Polar");
567 
568  // First fill the vector with the originally sampled coordinates
569  x.clear();
570  y.clear();
571  data.clear();
572  for (int i = 0; i < rings.size(); i++)
573  {
574  int nsam = XSIZE(rings[i]);
575  float dphi = TWOPI / (float)nsam;
576  float radius = ring_radius[i];
577  for (int j = 0; j < nsam; j++)
578  {
579  float tmp = j * dphi;
580  x.push_back(radius * sin(tmp));
581  y.push_back(radius * cos(tmp));
582  data.push_back(rings[i](j));
583  }
584  }
585 
586  // Add additional points on the inside and outside of the rings
587  // Add a maximum of "extra_shell" rings
588  // Set data to zero here
589  auto first_ring = (int)floor(ring_radius[0]);
590  auto last_ring = (int)ceil(ring_radius[rings.size()-1]);
591  int outer = last_ring + extra_shell;
592  int inner = XMIPP_MAX(0,first_ring - extra_shell);
593  for (int iradius = 0; iradius < outer; iradius +=1)
594  {
595  if ( (iradius >= inner && iradius < first_ring) ||
596  (iradius <= outer && iradius > last_ring) )
597  {
598  double radius=iradius;
599  int nsam = 2 * (int)( 0.5 * oversample * TWOPI * radius );
600  nsam = XMIPP_MAX(1, nsam);
601  float dphi = TWOPI / (float)nsam;
602  for (int j = 0; j < nsam; j++)
603  {
604  float tmp = j * dphi;
605  x.push_back(radius * sin(tmp));
606  y.push_back(radius * cos(tmp));
607  data.push_back(0.);
608  }
609  }
610  }
611  }
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
__host__ __device__ float2 floor(const float2 v)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
static double * y
#define TWOPI
Definition: xmipp_macros.h:111
double oversample
Definition: polar.h:73
doublereal * x
#define i
constexpr int FULL_CIRCLES
Definition: polar.h:40
std::vector< double > ring_radius
Definition: polar.h:74
#define XSIZE(v)
int mode
Definition: polar.h:72
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75
Incorrect value received.
Definition: xmipp_error.h:195

◆ getMode()

template<typename T>
int Polar< T >::getMode ( ) const
inline

Mode access

This function is used to know the "mode" of the polar.

There are two modes: FULL_CIRCLES = 0 (used for asymmetric functions) HALF_CIRCLES = 0 (used for symmetric functions, e.g. Fourier transforms)

std::cout << "Mode: " << P.getMode() << std::endl;

Definition at line 343 of file polar.h.

344  {
345  return mode;
346  }
int mode
Definition: polar.h:72

◆ getOversample()

template<typename T>
double Polar< T >::getOversample ( ) const
inline

Oversample access

This function is used to know the oversampling factor of the polar.

Oversample = 1 means there is no oversampling Oversample > 1 means oversampling Oversampling < 1 means undersampling

std::cout << "Oversample: " << P.getOversample() << std::endl;

Definition at line 360 of file polar.h.

361  {
362  return oversample;
363  }
double oversample
Definition: polar.h:73

◆ getPixel()

template<typename T>
T& Polar< T >::getPixel ( int  r,
int  f 
) const
inline

Pixel access

This operator is used to access a pixel within the polar. That means, given the ring and the number of the pixel in the rotational direction.

int ring = 1, phi = 0;
std::cout <<" first pixel of second ring= "<<P.getPixel(ring,phi)<<std::endl;

Definition at line 446 of file polar.h.

447  {
448  return rings[r](f);
449  }
double * f
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ getPolarFromCartesianBSpline()

template<typename T>
void Polar< T >::getPolarFromCartesianBSpline ( const MultidimArray< T > &  M1,
int  first_ring,
int  last_ring,
int  BsplineOrder = 3,
double  xoff = 0.,
double  yoff = 0.,
double  oversample1 = 1.,
int  mode1 = FULL_CIRCLES 
)
inline

Convert cartesian MultidimArray to Polar using B-spline interpolation

The input MultidimArray is assumed to be pre-processed for B-splines

img().produceSplineCoefficients(Maux,3);

Definition at line 625 of file polar.h.

629  {
630  double twopi;
631  double xp;
632  double yp;
633  double minxp;
634  double maxxp;
635  double minyp;
636  double maxyp;
637 
638  auto noOfRings = getNoOfRings(first_ring, last_ring);
639  rings.resize(noOfRings);
640  ring_radius.resize(noOfRings);
641 
642  mode = mode1;
643  oversample = oversample1;
644 
645  if (mode == FULL_CIRCLES)
646  twopi = TWOPI;
647  else if (mode == HALF_CIRCLES)
648  twopi = PI;
649  else
650  REPORT_ERROR(ERR_VALUE_INCORRECT,"Incorrect mode for getPolarFromCartesian");
651 
652 
653  // Limits of the matrix (not oversized!)
654  minxp = FIRST_XMIPP_INDEX(XSIZE(M1));
655  minyp = FIRST_XMIPP_INDEX(YSIZE(M1));
656  maxxp = LAST_XMIPP_INDEX(XSIZE(M1));
657  maxyp = LAST_XMIPP_INDEX(YSIZE(M1));
658  double minxp_e=minxp-XMIPP_EQUAL_ACCURACY;
659  double minyp_e=minyp-XMIPP_EQUAL_ACCURACY;
660  double maxxp_e=maxxp+XMIPP_EQUAL_ACCURACY;
661  double maxyp_e=maxyp+XMIPP_EQUAL_ACCURACY;
662 
663  std::lock_guard<std::mutex> lockGuard(m_mutex);
664 
665  ensureAngleCache(first_ring, last_ring);
666 
667  // Loop over all polar coordinates
668  for (int r = 0; r < noOfRings; ++r)
669  {
670  float radius = (float) r + first_ring;
671  ring_radius.at(r) = radius;
672  auto &Mring = rings.at(r);
673  // Non-constant sampling!! (always even for convenient Half2Whole of FTs)
674  int nsam = getNoOfSamples(twopi, radius);
675  Mring.resizeNoCopy(nsam);
676 
677  auto &s = m_lastSinRadius.at(r);
678  auto &c = m_lastCosRadius.at(r);
679 
680  for (int sample = 0; sample < nsam; ++sample)
681  {
682  // from polar to original cartesian coordinates
683  xp = s.at(sample);
684  yp = c.at(sample);
685 
686  // Origin offsets
687  xp += xoff;
688  yp += yoff;
689 
690  // Wrap coordinates
691  if (xp < minxp_e || xp > maxxp_e)
692  xp = realWRAP(xp, minxp - 0.5, maxxp + 0.5);
693  if (yp < minyp_e || yp > maxyp_e)
694  yp = realWRAP(yp, minyp - 0.5, maxyp + 0.5);
695 
696  // Perform the convolution interpolation
697  if (BsplineOrder==1)
698  DIRECT_A1D_ELEM(Mring,sample) = M1.interpolatedElement2DOutsideZero(xp,yp);
699  else
700  DIRECT_A1D_ELEM(Mring,sample) = M1.interpolatedElementBSpline2D(xp,yp,BsplineOrder);
701  }
702  }
703  }
#define YSIZE(v)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
doublereal * c
#define TWOPI
Definition: xmipp_macros.h:111
double oversample
Definition: polar.h:73
constexpr int FULL_CIRCLES
Definition: polar.h:40
#define DIRECT_A1D_ELEM(v, i)
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119
std::vector< double > ring_radius
Definition: polar.h:74
#define XSIZE(v)
constexpr int HALF_CIRCLES
Definition: polar.h:41
int mode
Definition: polar.h:72
T interpolatedElementBSpline2D(double x, double y, int SplineDegree=3) const
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
#define realWRAP(x, x0, xF)
Definition: xmipp_macros.h:304
T interpolatedElement2DOutsideZero(double x, double y) const
std::vector< MultidimArray< T > > rings
Definition: polar.h:75
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
#define PI
Definition: tools.h:43
Incorrect value received.
Definition: xmipp_error.h:195

◆ getRadius()

template<typename T>
double Polar< T >::getRadius ( int  iring) const
inline

The radius of each ring access

This function is used to know the radius of a given ring.

std::cout << "Radius of second ring: " << P.getRadius(1) << std::endl;

Definition at line 399 of file polar.h.

400  {
401  return ring_radius[iring];
402  }
std::vector< double > ring_radius
Definition: polar.h:74

◆ getRing() [1/2]

template<typename T>
MultidimArray< T >& Polar< T >::getRing ( int  i)
inline

1D Matrix access

This operator can be used to access any ring of the polar as MultidimArray.

MultidimArray<double> secondring = P.getRing(1);

Definition at line 412 of file polar.h.

413  {
414  return rings[i];
415  }
#define i
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ getRing() [2/2]

template<typename T>
const MultidimArray< T >& Polar< T >::getRing ( int  i) const
inline

Definition at line 416 of file polar.h.

417  {
418  return rings[i];
419  }
#define i
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ getRingNo()

template<typename T>
int Polar< T >::getRingNo ( ) const
inline

Number of rings access

This function is used to know the number of rings in the polar.

std::cout << "Number of rings: " << P.getRingNo() << std::endl;

Definition at line 326 of file polar.h.

327  {
328  return rings.size();
329  }
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ getSampleNo()

template<typename T>
int Polar< T >::getSampleNo ( int  iring) const
inline

Number of samples in each ring access

This function is used to know the number of samples in a given ring.

std::cout << "Number of samples in second ring: " << P.getSampleNo(1) << std::endl;

Definition at line 373 of file polar.h.

374  {
375  return XSIZE(rings[iring]);
376  }
#define XSIZE(v)
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ getSampleNoOuterRing()

template<typename T>
int Polar< T >::getSampleNoOuterRing ( ) const
inline

Number of samples in outer ring access

This function is used to know the number of samples in the outer ring.

std::cout << "Number of samples in outer ring: " << P.getSampleNoOuterRing() << std::endl;

Definition at line 386 of file polar.h.

387  {
388  return XSIZE(rings[rings.size()-1]);
389  }
#define XSIZE(v)
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ name()

template<typename T>
const FileName& Polar< T >::name ( ) const
inline

Name access

This function is used to know the name of the polar. It cannot be used to assign a new one. You may use rename() for that.

std::cout << "Polar name: " << P.name() << std::endl;

Definition at line 313 of file polar.h.

314  {
315  return fn_pol;
316  }
FileName fn_pol
Definition: polar.h:70

◆ normalize()

template<typename T>
void Polar< T >::normalize ( double  average,
double  stddev 
)
inline

Definition at line 536 of file polar.h.

537  {
538  size_t imax=rings.size();
539  double istddev=1.0/stddev;
540  for (size_t i = 0; i < imax; i++)
541  {
542  MultidimArray<T> &rings_i=rings[i];
543  for (size_t j = 0; j < XSIZE(rings_i); j++)
544  DIRECT_A1D_ELEM(rings_i,j) = (DIRECT_A1D_ELEM(rings_i,j)-average)*istddev;
545  }
546  }
#define i
#define DIRECT_A1D_ELEM(v, i)
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator()()

template<typename T>
T& Polar< T >::operator() ( int  r,
int  f 
) const
inline

Pixel access

This operator is used to access a pixel within the polar. That means, given the ring and the number of the pixel in the rotational direction.

int ring = 1, phi = 0;
std::cout <<" first pixel of second ring= "<<P(ring,phi)<<std::endl;

Definition at line 462 of file polar.h.

463  {
464  return DIRECT_A1D_ELEM(rings[r],f);
465  }
#define DIRECT_A1D_ELEM(v, i)
double * f
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator*()

template<typename T>
Polar& Polar< T >::operator* ( const T  val)
inline

Multiply by a constant pixel-by-pixel

Definition at line 160 of file polar.h.

161  {
162  Polar<T> result;
163  result = *(this);
164  for (size_t i = 0; i < rings.size(); i++)
165  for (size_t j = 0; j < XSIZE(rings[i]); j++)
166  result(i,j) *= val;
167 
168  return result;
169  }
#define i
#define XSIZE(v)
#define j
Definition: polar.h:67
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator*=() [1/2]

template<typename T>
void Polar< T >::operator*= ( const T  val)
inline

Multiply by a constant pixel-by-pixel

Definition at line 212 of file polar.h.

213  {
214  size_t imax=rings.size();
215  for (size_t i = 0; i < imax; i++)
216  {
217  MultidimArray<T> &rings_i=rings[i];
218  for (int j = 0; j < XSIZE(rings_i); j++)
219  DIRECT_A1D_ELEM(rings_i,j) *= val;
220  }
221  }
#define i
#define DIRECT_A1D_ELEM(v, i)
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator*=() [2/2]

template<typename T>
Polar& Polar< T >::operator*= ( const Polar< T >  in)
inline

Multiply two polars pixel-by-pixel

Definition at line 257 of file polar.h.

258  {
259  for (size_t i = 0; i < rings.size(); i++)
260  for (size_t j = 0; j < XSIZE(rings[i]); j++)
261  (*(this))(i,j) *= in(i,j);
262  }
#define i
int in
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator+()

template<typename T>
Polar& Polar< T >::operator+ ( const T  val)
inline

Add a constant pixel-by-pixel

Definition at line 147 of file polar.h.

148  {
149  Polar<T> result;
150  result = *(this);
151  for (size_t i = 0; i < rings.size(); i++)
152  for (size_t j = 0; j < XSIZE(rings[i]); j++)
153  result(i,j) += val;
154 
155  return result;
156  }
#define i
#define XSIZE(v)
#define j
Definition: polar.h:67
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator+=() [1/2]

template<typename T>
void Polar< T >::operator+= ( const T  val)
inline

Add a constant pixel-by-pixel

Definition at line 199 of file polar.h.

200  {
201  size_t imax=rings.size();
202  for (size_t i = 0; i < imax; i++)
203  {
204  MultidimArray<T> &rings_i=rings[i];
205  for (int j = 0; j < XSIZE(rings_i); j++)
206  DIRECT_A1D_ELEM(rings_i,j) += val;
207  }
208  }
#define i
#define DIRECT_A1D_ELEM(v, i)
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator+=() [2/2]

template<typename T>
Polar& Polar< T >::operator+= ( const Polar< T >  in)
inline

Add two polars pixel-by-pixel

Definition at line 248 of file polar.h.

249  {
250  for (size_t i = 0; i < rings.size(); i++)
251  for (size_t j = 0; j < XSIZE(rings[i]); j++)
252  (*(this))(i,j) += in(i,j);
253  }
#define i
int in
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator-()

template<typename T>
Polar& Polar< T >::operator- ( const T  val) const
inline

Subtract a constant pixel-by-pixel

Definition at line 134 of file polar.h.

135  {
136  Polar<T> result;
137  result = *(this);
138  for (size_t i = 0; i < rings.size(); i++)
139  for (size_t j = 0; j < XSIZE(rings[i]); j++)
140  result(i,j) -= val;
141 
142  return result;
143  }
#define i
#define XSIZE(v)
#define j
Definition: polar.h:67
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator-=() [1/2]

template<typename T>
void Polar< T >::operator-= ( const T  val)
inline

Subtract a constant pixel-by-pixel

Definition at line 186 of file polar.h.

187  {
188  size_t imax=rings.size();
189  for (size_t i = 0; i < imax; i++)
190  {
191  MultidimArray<T> &rings_i=rings[i];
192  for (size_t j = 0; j < XSIZE(rings_i); j++)
193  DIRECT_A1D_ELEM(rings_i,j) -= val;
194  }
195  }
#define i
#define DIRECT_A1D_ELEM(v, i)
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator-=() [2/2]

template<typename T>
Polar& Polar< T >::operator-= ( const Polar< T >  in)
inline

Subtract two polars pixel-by-pixel

Definition at line 239 of file polar.h.

240  {
241  for (size_t i = 0; i < rings.size(); i++)
242  for (size_t j = 0; j < XSIZE(rings[i]); j++)
243  (*(this))(i,j) -= in(i,j);
244  }
#define i
int in
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator/()

template<typename T>
Polar& Polar< T >::operator/ ( const T  val)
inline

Divide by a constant pixel-by-pixel

Definition at line 173 of file polar.h.

174  {
175  Polar<T> result;
176  result = *(this);
177  for (size_t i = 0; i < rings.size(); i++)
178  for (size_t j = 0; j < XSIZE(rings[i]); j++)
179  result(i,j) /= val;
180 
181  return result;
182  }
#define i
#define XSIZE(v)
#define j
Definition: polar.h:67
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator/=() [1/2]

template<typename T>
void Polar< T >::operator/= ( const T  val)
inline

Divide by a constant pixel-by-pixel

Definition at line 225 of file polar.h.

226  {
227  size_t imax=rings.size();
228  double ival=1.0/val;
229  for (size_t i = 0; i < imax; i++)
230  {
231  MultidimArray<T> &rings_i=rings[i];
232  for (size_t j = 0; j < XSIZE(rings_i); j++)
233  DIRECT_A1D_ELEM(rings_i,j) *= ival;
234  }
235  }
#define i
#define DIRECT_A1D_ELEM(v, i)
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator/=() [2/2]

template<typename T>
Polar& Polar< T >::operator/= ( const Polar< T >  in)
inline

Divide two polars pixel-by-pixel

Definition at line 266 of file polar.h.

267  {
268  for (size_t i = 0; i < rings.size(); i++)
269  for (size_t j = 0; j < XSIZE(rings[i]); j++)
270  (*(this))(i,j) /= in(i,j);
271  }
#define i
int in
#define XSIZE(v)
#define j
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ operator=()

template<typename T>
Polar& Polar< T >::operator= ( const Polar< T > &  P)
inline

Assignment

Definition at line 119 of file polar.h.

120  {
121  if (this != &P)
122  {
123  fn_pol = P.fn_pol;
124  rings = P.rings;
126  mode = P.mode;
128  }
129  return *this;
130  }
FileName fn_pol
Definition: polar.h:70
double oversample
Definition: polar.h:73
std::vector< double > ring_radius
Definition: polar.h:74
int mode
Definition: polar.h:72
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ rename()

template<typename T>
void Polar< T >::rename ( const FileName newName)
inline

Rename polar

Give a new name to the polar.

P.rename("new_name");

Definition at line 282 of file polar.h.

283  {
284  fn_pol = newName;
285  }
FileName fn_pol
Definition: polar.h:70

◆ setPixel()

template<typename T>
void Polar< T >::setPixel ( int  r,
int  f,
val 
) const
inline

Pixel access

This operator is used to set a pixel within the polar. That means, given the ring and the number of the pixel in the rotational direction.

int ring = 1, phi = 0;
double val = 1.2;
P.setPixel(ring,phi,val);

Definition at line 479 of file polar.h.

480  {
481  rings[r](f) = val;
482  }
double * f
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

◆ setRing()

template<typename T>
void Polar< T >::setRing ( int  i,
MultidimArray< T >  val 
)
inline

1D Matrix access

This operator can be used to set any ring of the polar with a MultidimArray.

P.setRing(1,ring);

Definition at line 430 of file polar.h.

431  {
432  rings[i] = val;
433  }
#define i
std::vector< MultidimArray< T > > rings
Definition: polar.h:75

Member Data Documentation

◆ fn_pol

template<typename T>
FileName Polar< T >::fn_pol
protected

Definition at line 70 of file polar.h.

◆ mode

template<typename T>
int Polar< T >::mode

Definition at line 72 of file polar.h.

◆ oversample

template<typename T>
double Polar< T >::oversample

Definition at line 73 of file polar.h.

◆ ring_radius

template<typename T>
std::vector<double> Polar< T >::ring_radius

Definition at line 74 of file polar.h.

◆ rings

template<typename T>
std::vector<MultidimArray<T> > Polar< T >::rings

Definition at line 75 of file polar.h.


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