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

#include <phantom.h>

Inheritance diagram for Gaussian:
Inheritance graph
[legend]
Collaboration diagram for Gaussian:
Collaboration graph
[legend]

Public Member Functions

void prepare ()
 
void assign (const Gaussian &F)
 
int point_inside (const Matrix1D< double > &r, Matrix1D< double > &aux) const
 
double density_inside (const Matrix1D< double > &r, Matrix1D< double > &aux) const
 
Featurescale (double factor) const
 
 __attribute__ ((deprecated)) void scale(double factor
 
double intersection (const Matrix1D< double > &direction, const Matrix1D< double > &passing_point, Matrix1D< double > &r, Matrix1D< double > &u) const
 
double volume () const
 
void read_specific (char *line)
 
void read_specific (const std::vector< double > &vect)
 
void feat_printf (FILE *fh) const
 
void feat_printm (MetaData &MD, size_t id)
 
void init_rnd (double minsigma, double maxsigma, double minden=1.0, double maxden=1.0, double minx0=0, double maxx0=0, double miny0=0, double maxy0=0, double minz0=0, double maxz0=0)
 
- Public Member Functions inherited from Feature
void assign (const Feature &F)
 
virtual void rotate (const Matrix2D< double > &E)
 
virtual void rotate_center (const Matrix2D< double > &E)
 
int point_inside (const Matrix1D< double > &r) const
 
int voxel_inside (const Matrix1D< double > &r, Matrix1D< double > &aux1, Matrix1D< double > &aux2) const
 
int voxel_inside (const Matrix1D< double > &r) const
 
double voxel_inside_by_normalized_density (const Matrix1D< double > &r, Matrix1D< double > &aux1, Matrix1D< double > &aux2) const
 
int intersects_sphere (const Matrix1D< double > &r, double radius, Matrix1D< double > &aux1, Matrix1D< double > &aux2, Matrix1D< double > &aux3) const
 
int intersects_sphere (const Matrix1D< double > &r, double radius) const
 
Featureencircle (double radius=0) const
 
Featurebackground (int back_mode, double back_param) const
 
double intersection (const Matrix1D< double > &direction, const Matrix1D< double > &passing_point) const
 
void mean_variance_in_plane (Image< double > *V, double z, double &mean, double &var)
 
void project_to (Projection &P, const Matrix2D< double > &VP, const Matrix2D< double > &PV) const
 
void corners (const MultidimArray< double > &V, Matrix1D< double > &corner1, Matrix1D< double > &corner2)
 
void draw_in (MultidimArray< double > &V, int color_mode=INTERNAL, double colour=-1)
 
void sketch_in (MultidimArray< double > &V, double colour=2)
 
void shift (double shiftX, double shiftY, double shiftZ)
 
void selfApplyGeometry (const Matrix2D< double > &A)
 
void readCommon (char *line)
 
void readCommon (MDRow &row)
 
void read (MDRow &row)
 

Public Attributes

double sigma
 Sigma. More...
 
Feature **_f const
 
- Public Attributes inherited from Feature
std::string type
 
char add_assign
 
double density
 
Matrix1D< double > center
 
double max_distance
 

Friends

std::ostream & operator<< (std::ostream &o, const Gaussian &f)
 

Detailed Description

Gaussians. The Gaussians are defined by its center, and sigma. The label is "gau".

A point (r) in the universal coordinate system, where Gaussians are defined in general, can be expressed (rp) with respect to a system where the Gaussian is centered at the origin and its sigma is unity by

V3_MINUS_V3(rp,r,gau.Center);
V3_BY_CT(rp, rp, 1/sigma);

Directions (free vectors) are transformed in the same fashion except that for the first vector subtraction (referring to the origin).

Definition at line 661 of file phantom.h.

Member Function Documentation

◆ __attribute__()

Gaussian::__attribute__ ( (deprecated)  )

Another function for return a scaled Blob.

◆ assign()

void Gaussian::assign ( const Gaussian F)

Another function for assignment.

Definition at line 118 of file phantom.cpp.

119 {
120  *this = F;
121 }

◆ density_inside()

double Gaussian::density_inside ( const Matrix1D< double > &  r,
Matrix1D< double > &  aux 
) const
virtual

Density inside a Gaussian. This function tells you the density of the Gaussian at point r

Implements Feature.

Definition at line 726 of file phantom.cpp.

727 {
728  /*Express r in the feature coord. system*/
729  V3_MINUS_V3(aux, r, center);
730  /*Calculate density*/
731  const double norm=1.0/sqrt(2.0*PI);
732  double rmod=aux.module();
733  double sigma2=sigma*sigma;
734  return norm/(sigma2*sigma)*exp(-0.5*rmod*rmod/sigma2);
735 }
double module() const
Definition: matrix1d.h:983
double sigma
Sigma.
Definition: phantom.h:666
void sqrt(Image< double > &op)
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
T norm(const std::vector< T > &v)
Definition: vector_ops.h:399
#define PI
Definition: tools.h:43

◆ feat_printf()

void Gaussian::feat_printf ( FILE *  fh) const
virtual

Print Gaussian in the standard feature format. \ See {Feature::feat_printf}, Phantoms

Implements Feature.

Definition at line 440 of file phantom.cpp.

441 {
442  fprintf(fh, "blo %c %1.4f % 7.2f % 7.2f % 7.2f % 7.2f\n",
444  sigma);
445 }
double sigma
Sigma.
Definition: phantom.h:666
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
char add_assign
Definition: phantom.h:108
#define XX(v)
Definition: matrix1d.h:85
#define YY(v)
Definition: matrix1d.h:93
fprintf(glob_prnt.io, "\)
#define ZZ(v)
Definition: matrix1d.h:101

◆ feat_printm()

void Gaussian::feat_printm ( MetaData MD,
size_t  id 
)
virtual

Implements Feature.

Definition at line 448 of file phantom.cpp.

449 {
450  std::vector<double> FSVect;
451  FSVect.push_back(sigma);
453 }
double sigma
Sigma.
Definition: phantom.h:666
Specific parameters for a feature (vector double)
bool setValue(const MDLabel label, const T &valueIn, size_t id)

◆ init_rnd()

void Gaussian::init_rnd ( double  minsigma,
double  maxsigma,
double  minden = 1.0,
double  maxden = 1.0,
double  minx0 = 0,
double  maxx0 = 0,
double  miny0 = 0,
double  maxy0 = 0,
double  minz0 = 0,
double  maxz0 = 0 
)

Generate a random Gaussian. A sphere is generated randomly within the range of the parameters given. Notice that most of them are set by default. The exact parameters are picked uniformly from the range. The maximum distance is adjusted properly according to the randomly generated feature. 'den' stands for density and (x0,y0,z0) is the center of the feature. The behaviour of the new sphere is always Add

Definition at line 1726 of file phantom.cpp.

1732 {
1734  center.resize(3);
1735  type = "gau";
1736  add_assign = '+';
1737  density = rnd_unif(minden, maxden);
1738  XX(center) = rnd_unif(minx0, maxx0);
1739  YY(center) = rnd_unif(miny0, maxy0);
1740  ZZ(center) = rnd_unif(minz0, maxz0);
1741 
1742  sigma = rnd_unif(minsigma, maxsigma);
1743  max_distance = 4*sigma;
1744 }
double sigma
Sigma.
Definition: phantom.h:666
Matrix1D< double > center
Definition: phantom.h:119
double density
Definition: phantom.h:114
char add_assign
Definition: phantom.h:108
double rnd_unif()
#define XX(v)
Definition: matrix1d.h:85
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
double max_distance
Definition: phantom.h:126
#define YY(v)
Definition: matrix1d.h:93
std::string type
Definition: phantom.h:101
unsigned int randomize_random_generator()
#define ZZ(v)
Definition: matrix1d.h:101

◆ intersection()

double Gaussian::intersection ( const Matrix1D< double > &  direction,
const Matrix1D< double > &  passing_point,
Matrix1D< double > &  r,
Matrix1D< double > &  u 
) const
virtual

Intersection of a ray with a Gaussian. See Feature::intersection to know more about the parameters meaning.

Implements Feature.

Definition at line 1131 of file phantom.cpp.

1136 {
1137  double rmod=point_line_distance_3D(center, passing_point, direction);
1138  double sigma2=sigma*sigma;
1139  return 1.0/sigma2*exp(-0.5*rmod*rmod/sigma2);
1140 }
double point_line_distance_3D(const Matrix1D< double > &p, const Matrix1D< double > &a, const Matrix1D< double > &v)
Definition: geometry.cpp:85
double sigma
Sigma.
Definition: phantom.h:666
Matrix1D< double > center
Definition: phantom.h:119

◆ point_inside()

int Gaussian::point_inside ( const Matrix1D< double > &  r,
Matrix1D< double > &  aux 
) const
virtual

Speeded up point inside a Gaussian. This function tells you if a point is inside the Gaussian or not. See Feature::point_inside

Implements Feature.

Definition at line 717 of file phantom.cpp.

718 {
719  V3_MINUS_V3(aux,r,center);
720  if (XX(aux)*XX(aux) + YY(aux)*YY(aux) +ZZ(aux)*ZZ(aux) <= 16*sigma*sigma)
721  return 1;
722  return 0;
723 }
double sigma
Sigma.
Definition: phantom.h:666
#define V3_MINUS_V3(a, b, c)
Definition: matrix1d.h:202
Matrix1D< double > center
Definition: phantom.h:119
#define XX(v)
Definition: matrix1d.h:85
#define YY(v)
Definition: matrix1d.h:93
#define ZZ(v)
Definition: matrix1d.h:101

◆ prepare()

void Gaussian::prepare ( )
virtual

Prepare Gaussian for work. Computes the maximum distance, in this case, equal to "4sigma"

Implements Feature.

Definition at line 54 of file phantom.cpp.

55 {
56  max_distance = 4*sigma;
57 }
double sigma
Sigma.
Definition: phantom.h:666
double max_distance
Definition: phantom.h:126

◆ read_specific() [1/2]

void Gaussian::read_specific ( char *  line)

Read specific description for a Gaussian. An exception is thrown if the line doesn't conform the standard specification. See Feature::read_specific

Definition at line 264 of file phantom.cpp.

265 {
266  int stat;
267  stat = sscanf(line, "%*s %*c %*f %*f %*f %*f %lf", &sigma);
268  if (stat != 1)
269  REPORT_ERROR(ERR_IO_NOREAD, (std::string)"Error when reading a Gaussian:" + line);
270  prepare();
271 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double sigma
Sigma.
Definition: phantom.h:666
void prepare()
Definition: phantom.cpp:54
Couldn&#39;t read from file.
Definition: xmipp_error.h:139

◆ read_specific() [2/2]

void Gaussian::read_specific ( const std::vector< double > &  vector)
virtual

Read a feature from a file, VIRTUAL!!!. The format must be the one given in Phantoms, and each subclass must implement its own I/O routines. These routines must fill only the non common part of the feature description, but they receive the whole line with the description.

Implements Feature.

Definition at line 274 of file phantom.cpp.

275 {
276  if (vect.size() != 1)
277  REPORT_ERROR(ERR_ARG_MISSING, MDL::label2Str(MDL_PHANTOM_FEATURE_SPECIFIC) + "Error when reading a Gaussian");
278  sigma = vect[0];
279  prepare();
280 }
Argument missing.
Definition: xmipp_error.h:114
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double sigma
Sigma.
Definition: phantom.h:666
void prepare()
Definition: phantom.cpp:54
Specific parameters for a feature (vector double)
static String label2Str(const MDLabel &label)

◆ scale()

void Gaussian::scale ( double  factor) const
virtual

Return a scaled Gaussian. The center, density, and behaviour of the new Gaussian is exactly the same as the actual one. The radius is multiplied by the scale factor and the maximum distance is recalculated for the new sphere. Alpha is kept constant

Implements Feature.

Definition at line 1521 of file phantom.cpp.

1522 {
1523  Gaussian *f;
1524  f = new Gaussian;
1526 
1527  f->sigma = factor * sigma;
1528  f->prepare();
1529  return (Feature *)f;
1530 }
double sigma
Sigma.
Definition: phantom.h:666
void prepare()
Definition: phantom.cpp:54
#define COPY_COMMON_PART
Definition: phantom.cpp:1473
double * f

◆ volume()

double Gaussian::volume ( ) const
inlinevirtual

Mass of a Gaussian. This function returns mass inside a Gaussian. 3 is the dimension See Feature::volume

Implements Feature.

Definition at line 704 of file phantom.h.

705  {
706  return 1;
707  }

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  o,
const Gaussian f 
)
friend

Show feature not in the standard format but more informatively. This function only shows the non common part of the feature. Use the << operator of Feature to show the whole feature.

Definition at line 615 of file phantom.cpp.

616 {
617  o << " Sigma: " << f.sigma << std::endl;
618  return o;
619 }
double sigma
Sigma.
Definition: phantom.h:666

Member Data Documentation

◆ const

Feature** _f Gaussian::const

Definition at line 692 of file phantom.h.

◆ sigma

double Gaussian::sigma

Sigma.

Definition at line 666 of file phantom.h.


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