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

Public Member Functions

void readParams ()
 Read parameters from command line. More...
 
void defineParams ()
 define parameters More...
 
void run ()
 Run. More...
 
- 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 fnVol
 Volume to convert. More...
 
FileName fnCentralSlices
 Output central slices. More...
 
FileName fnProjections
 Output projections. More...
 
int Nslices
 Number of slices. More...
 
int maxWidth
 Maximum Width. More...
 
int sep
 Separation. 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 29 of file volume_to_web.cpp.

Member Function Documentation

◆ defineParams()

void ProgVolumeToWeb::defineParams ( )
inlinevirtual

define parameters

Reimplemented from XmippProgram.

Definition at line 66 of file volume_to_web.cpp.

67  {
68  addUsageLine("Creates a representation for the web of the input volume");
69  addParamsLine(" -i <volume> : Input volume");
70  addParamsLine(" [--central_slices <imgFile> <n=-1>] : Output central slices (normally jpg); n=-1 for all slices");
71  addParamsLine(" [--projections <imgFile>] : Output projections (normally jpg)");
72  addParamsLine(" [--maxWidth <w=800>] : Maximum image width");
73  addParamsLine(" [--separation <s=2>] : Separation in pixels between slices");
74  addExampleLine("xmipp_volume_to_web -i volume.vol --central_slices central_slices.jpg --projections projections.jpg");
75  }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgVolumeToWeb::readParams ( )
inlinevirtual

Read parameters from command line.

Reimplemented from XmippProgram.

Definition at line 51 of file volume_to_web.cpp.

52  {
53  fnVol=getParam("-i");
54  if (checkParam("--central_slices"))
55  {
56  fnCentralSlices=getParam("--central_slices");
57  Nslices=getIntParam("--central_slices",1);
58  }
59  if (checkParam("--projections"))
60  fnProjections=getParam("--projections");
61  maxWidth=getIntParam("--maxWidth");
62  sep=getIntParam("--separation");
63  }
int maxWidth
Maximum Width.
FileName fnVol
Volume to convert.
FileName fnCentralSlices
Output central slices.
FileName fnProjections
Output projections.
int sep
Separation.
const char * getParam(const char *param, int arg=0)
int Nslices
Number of slices.
bool checkParam(const char *param)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgVolumeToWeb::run ( )
inlinevirtual

Run.

Reimplemented from XmippProgram.

Definition at line 78 of file volume_to_web.cpp.

79  {
80  Image<double> V;
81  V.read(fnVol);
82  MultidimArray<double> &mV=V();
83 
84  Image<double> I;
85  if (!fnCentralSlices.empty())
86  {
87  // Choose the starting and finishing slice
88  if (Nslices==-1)
89  Nslices=ZSIZE(mV);
90  int kmiddle=ZSIZE(mV)/2;
91  int k0=kmiddle-Nslices/2;
92  int kF=k0+Nslices-1;
93 
94  // Resize the output image
95  int NslicesPerRow=maxWidth/XSIZE(mV);
96  if (NslicesPerRow==0)
97  NslicesPerRow=1;
98  else if (NslicesPerRow>Nslices)
99  NslicesPerRow=Nslices;
100  auto Nrows=(int)ceil(((float)Nslices)/NslicesPerRow);
101  if (Nrows==0)
102  Nrows=1;
103  I().resizeNoCopy(Nrows*YSIZE(mV)+(Nrows-1)*sep,NslicesPerRow*XSIZE(mV)+(NslicesPerRow-1)*sep);
104  I().initConstant(mV.computeMax());
105 
106  // Copy the slices into the output image
107  int outI=0, outJ=0;
108  for (int k=k0; k<=kF; ++k)
109  {
110  int outi=outI*(YSIZE(mV)+sep);
111  int outj=outJ*(XSIZE(mV)+sep);
112  for (size_t i=0; i<YSIZE(mV); ++i, ++outi)
113  memcpy(&IMGPIXEL(I,outi,outj),&A3D_ELEM(mV,k,i,0),XSIZE(mV)*sizeof(double));
114  outJ++;
115  if (outJ==NslicesPerRow)
116  {
117  outJ=0;
118  outI++;
119  }
120  }
121  I().rangeAdjust(0,255);
123  }
124  if (fnProjections!="")
125  {
126  // Take projections
127  MultidimArray<double> pXY, pYZ, pXZ;
128  pXY.initZeros(YSIZE(mV),XSIZE(mV));
129  pXZ.initZeros(ZSIZE(mV),XSIZE(mV));
130  pYZ.initZeros(ZSIZE(mV),YSIZE(mV));
131  double maxVal=-1e38;
133  {
134  double v=A3D_ELEM(mV,k,i,j);
135  A2D_ELEM(pXY,i,j)+=v;
136  A2D_ELEM(pXZ,k,j)+=v;
137  A2D_ELEM(pYZ,k,i)+=v;
138  maxVal=std::max(A2D_ELEM(pXY,i,j),maxVal);
139  maxVal=std::max(A2D_ELEM(pXZ,k,j),maxVal);
140  maxVal=std::max(A2D_ELEM(pYZ,k,i),maxVal);
141  }
142 
143  // Now produce output image
144  I().resizeNoCopy(XMIPP_MAX(YSIZE(mV),ZSIZE(mV)),2*(XSIZE(mV)+sep)+YSIZE(mV));
145  I().initConstant(maxVal);
146  int outi=0, outj=0;
147  for (size_t i=0; i<YSIZE(pXY); ++i, ++outi)
148  memcpy(&IMGPIXEL(I,outi,outj),&A2D_ELEM(pXY,i,0),XSIZE(pXY)*sizeof(double));
149 
150  outi=0;
151  outj=XSIZE(mV)+sep;
152  for (size_t i=0; i<YSIZE(pXZ); ++i, ++outi)
153  memcpy(&IMGPIXEL(I,outi,outj),&A2D_ELEM(pXZ,i,0),XSIZE(pXZ)*sizeof(double));
154 
155  outi=0;
156  outj=2*(XSIZE(mV)+sep);
157  for (size_t i=0; i<YSIZE(pYZ); ++i, ++outi)
158  memcpy(&IMGPIXEL(I,outi,outj),&A2D_ELEM(pYZ,i,0),XSIZE(pYZ)*sizeof(double));
159 
160  I().rangeAdjust(0,255);
161  I.write(fnProjections);
162  }
163  }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
int maxWidth
Maximum Width.
FileName fnVol
Volume to convert.
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)
FileName fnCentralSlices
Output central slices.
FileName fnProjections
Output projections.
int sep
Separation.
#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
#define A3D_ELEM(V, k, i, j)
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
#define XSIZE(v)
int Nslices
Number of slices.
void max(Image< double > &op1, const Image< double > &op2)
#define ZSIZE(v)
#define j
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void initZeros(const MultidimArray< T1 > &op)
#define IMGPIXEL(I, i, j)
T computeMax() const

Member Data Documentation

◆ fnCentralSlices

FileName ProgVolumeToWeb::fnCentralSlices

Output central slices.

Definition at line 36 of file volume_to_web.cpp.

◆ fnProjections

FileName ProgVolumeToWeb::fnProjections

Output projections.

Definition at line 39 of file volume_to_web.cpp.

◆ fnVol

FileName ProgVolumeToWeb::fnVol

Volume to convert.

Definition at line 33 of file volume_to_web.cpp.

◆ maxWidth

int ProgVolumeToWeb::maxWidth

Maximum Width.

Definition at line 45 of file volume_to_web.cpp.

◆ Nslices

int ProgVolumeToWeb::Nslices

Number of slices.

Definition at line 42 of file volume_to_web.cpp.

◆ sep

int ProgVolumeToWeb::sep

Separation.

Definition at line 48 of file volume_to_web.cpp.


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