Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
ProgFindCenter2D Class Reference
Inheritance diagram for ProgFindCenter2D:
Inheritance graph
[legend]
Collaboration diagram for ProgFindCenter2D:
Collaboration graph
[legend]

Public Member Functions

void defineParams ()
 Define parameters. More...
 
void readParams ()
 
void show ()
 
void run ()
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void show () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Public Attributes

FileName fnIn
 Filenames. More...
 
FileName fnOroot
 
double _r1
 Radii. More...
 
double _r2
 
double _r3
 
double _r4
 
double x0
 Starting center. More...
 
double y0
 
int _ncic
 Harmonic. More...
 
int _indmul
 Optimization type. More...
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

Definition at line 592 of file image_find_center.cpp.

Member Function Documentation

◆ defineParams()

void ProgFindCenter2D::defineParams ( )
inlinevirtual

Define parameters.

Reimplemented from XmippProgram.

Definition at line 611 of file image_find_center.cpp.

612  {
613  addUsageLine("Find the best symmetry of rotation of an image or collection of images");
614  addUsageLine("+It is very useful when you want to calculate the rotational symmetry of ");
615  addUsageLine("+a set of images (in fact it computes the center of the average image). ");
616  addUsageLine("+Image dimensions must be less than 512x512.");
617  addSeeAlsoLine("xmipp_image_rotational_spectrum");
618  addParamsLine(" -i <file> : Image, image stack or image selfile");
619  addParamsLine(" --oroot <rootname> : Rootname for output files");
620  addParamsLine(" :+ <rootname>_center.xmd contains the image center");
621  addParamsLine(" :+ <rootname>_analyzed_image.xmp (if verbose>=2) contains the image that was actually analyzed");
622  addParamsLine("[--r1+ <radius=15>] : Lowest integration radius (% of the image radius)");
623  addParamsLine("[--r2+ <radius=80>] : Highest integration radius (% of the image radius)");
624  addParamsLine("[--r3+ <radius=90>] : Lowest smoothing radius (% of the image radius)");
625  addParamsLine("[--r4+ <radius=100>] : Highest smoothing radius (% of the image radius)");
626  addParamsLine("[--x0 <x>] : Initial center of rotation");
627  addParamsLine("[--y0 <y>] : Initial center of rotation");
628  addParamsLine("[--harm+ <n=1>] : Harmonic to optimize");
629  addParamsLine("[--opt+ <opt=-1>] : Type of optimization (-1=minimize, +1=maximize)");
630  addExampleLine("xmipp_image_find_center -i image.xmp");
631  }
void addSeeAlsoLine(const char *seeAlso)
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgFindCenter2D::readParams ( )
inlinevirtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from XmippProgram.

Definition at line 633 of file image_find_center.cpp.

634  {
635  fnIn=getParam("-i");
636  fnOroot=getParam("--oroot");
637  _r1=getDoubleParam("--r1");
638  _r2=getDoubleParam("--r2");
639  _r3=getDoubleParam("--r3");
640  _r4=getDoubleParam("--r4");
641  if (checkParam("--x0"))
642  x0=getDoubleParam("--x0");
643  else
644  x0=-1;
645  if (checkParam("--y0"))
646  y0=getDoubleParam("--y0");
647  else
648  y0=-1;
649  _ncic=getIntParam("--harm");
650  _indmul=getIntParam("--opt");
651  }
double getDoubleParam(const char *param, int arg=0)
const char * getParam(const char *param, int arg=0)
int _indmul
Optimization type.
FileName fnIn
Filenames.
double x0
Starting center.
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgFindCenter2D::run ( )
inlinevirtual

This function will be start running the program. it also should be implemented by derived classes.

Reimplemented from XmippProgram.

Definition at line 669 of file image_find_center.cpp.

670  {
671  show();
672  size_t id;
673  // Get the input image or the average of the input images
674  Image<double> I, Iaux;
675  if (fnIn.isMetaData())
676  {
677  MetaDataVec MD(fnIn);
678  int N=0;
679  for (size_t objId : MD.ids())
680  {
681  Iaux.readApplyGeo(MD, objId);
682  if (N==0)
683  I()=Iaux();
684  else
685  I()+=Iaux();
686  ++N;
687  }
688  I()/=N;
689  }
690  else
691  {
692  I.read(fnIn, HEADER);
693  size_t Xdim, Ydim, Zdim, Ndim;
694  I.getDimensions(Xdim, Ydim, Zdim, Ndim);
695  I.clear();
696  if (Ndim>1)
697  {
698  for (size_t n = FIRST_IMAGE; n <= Ndim; n++)
699  {
700  Iaux.read(fnIn,DATA,n);
701  if (n == FIRST_IMAGE)
702  I=Iaux;
703  else
704  I()+=Iaux();
705  }
706  I()/=Ndim;
707  }
708  else
709  I.read(fnIn);
710  }
711  I().rangeAdjust(0,255);
712  if (verbose==2)
713  I.write(fnOroot+"_analyzed_image.xmp");
714 
715  // Adapt to old code
716  if ((imagen = (unsigned char **)imalloc(YSIZE(I()) + 1, XSIZE(I()) + 1, NATURAL)) == NULL)
719  imagen[i+1][j+1]=(unsigned char)IMGPIXEL(I,i,j);
720  if (x0>=0)
721  xc0=(float)x0+1; //+1 because of Fortran indexing
722  else
723  xc0=XSIZE(I())/2+1;
724  if (y0>=0)
725  yc0=(float)y0+1;
726  else
727  yc0=YSIZE(I())/2+1;
728  r1=(float)(_r1/100.0*XSIZE(I())/2.0);
729  r2=(float)(_r2/100.0*XSIZE(I())/2.0);
730  r3=1;
731  rbajo=(float)(_r3/100.0*XSIZE(I())/2.0);
732  ralto=(float)(_r4/100.0*XSIZE(I())/2.0);
733  ncic=_ncic;
734  indmul=_indmul;
735  del = DEF_DEL;
736  in = DEF_IN;
737  ni = DEF_IT;
738  mu = (int)(PI / 2 * r2 / ncic);
739  if (mu < 3)
740  REPORT_ERROR(ERR_ARG_INCORRECT,"A higher integration radius is needed (r2>6*harm/pi)");
741  largo=YSIZE(I());
742  lancho=XSIZE(I());
743  busca();
744  MetaDataVec MD;
745  id=MD.addObject();
746  if (yc0>0)
747  {
748  MD.setValue(MDL_X,(double)(yc0-1),id);
749  MD.setValue(MDL_Y,(double)(xc0-1),id);
750  }
751  else
752  {
753  MD.setValue(MDL_X,(double)(XSIZE(I())/2),id);
754  MD.setValue(MDL_Y,(double)(YSIZE(I())/2),id);
755  }
756  MD.write(fnOroot+"_center.xmd");
757  imfree((char**)imagen, YSIZE(I()) + 1, XSIZE(I()) + 1, NATURAL);
758  }
#define YSIZE(v)
BYTE ** imagen
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
float del
There is not enough memory for allocation.
Definition: xmipp_error.h:166
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
void imfree(char **image, int row, int col, int format)
float xc0
int largo
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams &params=DefaultApplyGeoParams)
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
if(fabs(c[*nmax+ *nmax *c_dim1])==0.e0)
bool setValue(const MDObject &mdValueIn, size_t id)
int indmul
int in
Incorrect argument received.
Definition: xmipp_error.h:113
#define XSIZE(v)
int _indmul
Optimization type.
int verbose
Verbosity level.
int ni
#define j
FileName fnIn
Filenames.
double x0
Starting center.
bool isMetaData(bool failIfNotExists=true) const
float ralto
int ncic
void ** imalloc(int row, int col, int format)
Y component (double)
float r3
float yc0
X component (double)
int mu
int lancho
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
#define FIRST_IMAGE
float r2
constexpr int DEF_IN
#define pi
float rbajo
void busca()
#define PI
Definition: tools.h:43
int * n
void clear()
Definition: xmipp_image.h:144
constexpr int DEF_DEL
#define IMGPIXEL(I, i, j)
float r1
constexpr int DEF_IT
void getDimensions(size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const

◆ show()

void ProgFindCenter2D::show ( )
inline

Definition at line 653 of file image_find_center.cpp.

654  {
655  if (verbose==0)
656  return;
657  std::cout << "Input: " << fnIn << std::endl
658  << "Output root: " << fnOroot << std::endl
659  << "R1: " << _r1 << std::endl
660  << "R2: " << _r2 << std::endl
661  << "R3: " << _r3 << std::endl
662  << "R4: " << _r4 << std::endl
663  << "Harmonic: " << _ncic << std::endl
664  << "Opt: " << _indmul << std::endl
665  << "Initial center: (" << x0 << "," << y0 << ")\n"
666  ;
667  }
int _indmul
Optimization type.
int verbose
Verbosity level.
FileName fnIn
Filenames.
double x0
Starting center.

Member Data Documentation

◆ _indmul

int ProgFindCenter2D::_indmul

Optimization type.

Definition at line 608 of file image_find_center.cpp.

◆ _ncic

int ProgFindCenter2D::_ncic

Harmonic.

Definition at line 605 of file image_find_center.cpp.

◆ _r1

double ProgFindCenter2D::_r1

Radii.

Definition at line 599 of file image_find_center.cpp.

◆ _r2

double ProgFindCenter2D::_r2

Definition at line 599 of file image_find_center.cpp.

◆ _r3

double ProgFindCenter2D::_r3

Definition at line 599 of file image_find_center.cpp.

◆ _r4

double ProgFindCenter2D::_r4

Definition at line 599 of file image_find_center.cpp.

◆ fnIn

FileName ProgFindCenter2D::fnIn

Filenames.

Definition at line 596 of file image_find_center.cpp.

◆ fnOroot

FileName ProgFindCenter2D::fnOroot

Definition at line 596 of file image_find_center.cpp.

◆ x0

double ProgFindCenter2D::x0

Starting center.

Definition at line 602 of file image_find_center.cpp.

◆ y0

double ProgFindCenter2D::y0

Definition at line 602 of file image_find_center.cpp.


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