45 addUsageLine(
"Apply geometric transformations to images. You can shift, rotate and scale a group of images/volumes.");
46 addUsageLine(
"+ By default the geometric transformations will be read from a metadata, if provided. Also, ");
47 addUsageLine(
"+ the original images will be preserved if possible, trying to write out transformations to ");
48 addUsageLine(
"+ the output metadata. If output is not specified, the original files will be overwritten.");
49 addUsageLine(
"+ When output param -o is a stack file, associated metadata file is also generated using same rootname.");
50 addUsageLine(
"+ If geometrical transformation are applied, involved labels are reset in output metadata.");
52 addKeywords(
"transform, geometry, shift, rotate, scale, flip");
55 addParamsLine(
"[--rotate <ang=0>] : Inplane rotation in 2D images.");
57 addParamsLine(
"[--rotate_volume <rotation_type>] : Rotation of volumes.");
59 addParamsLine(
" euler <rot> <tilt> <psi> : Rotate with these Euler angles (ZYZ convention)");
60 addParamsLine(
" matrix <r11> <r12> <r13> <r21> <r22> <r23> <r31> <r32> <r33> : 3x3 rotation matrix, first index is row");
61 addParamsLine(
" alignZ <x> <y> <z> : Align (x,y,z) with Z axis");
62 addParamsLine(
" axis <ang> <x=0> <y=0> <z=1> : Rotate <ang> degrees around (x,y,z)");
63 addParamsLine(
" icosahedral <from> <to> : Rotate an icosahedral volume from i1 to i2, for instance");
65 addParamsLine(
"[--scale <factor=1>] : Perfom Scaling. Factor 0.5 halves and 2 doubles");
67 addParamsLine(
"[--shift <x=0> <y=0> <z=0>] : Shift by x, y and z");
69 addParamsLine(
"[--matrix <...>] : Apply directly the matrix transformation");
71 addParamsLine(
" [--interp <interpolation_type=spline>] : Interpolation type to be used. ");
74 addParamsLine(
" linear : Use bilinear/trilinear interpolation");
76 addParamsLine(
"[--apply_transform] : By default, the original images are preserved");
77 addParamsLine(
" : and the alignment information is stored in metadata");
78 addParamsLine(
"[--dont_wrap] : By default, the image/volume is wrapped");
79 addParamsLine(
"[--write_matrix] : Print transformation matrix to screen");
80 addParamsLine(
"[--shift_to <x=0> <y=0> <z=0>] : Shift each particle to x,y,z position");
82 addExampleLine(
"Write a metadata with geometrical transformations keeping the reference to original images:",
false);
83 addExampleLine(
"xmipp_transform_geometry -i mD1.xmd --shift 2 3 4 --scale 1.2 --rotate 23 -o newGeo.xmd");
84 addExampleLine(
"Write a metadata with geometrical transformations copying original images to new stack file:",
false);
85 addExampleLine(
"xmipp_transform_geometry -i mD1.xmd --shift 2 3 4 --scale 1.2 --rotate 23 -o newGeo.stk");
86 addExampleLine(
"Apply geometrical transformations to images ,reset involved labels and save in new metadata and stack files:",
false);
87 addExampleLine(
"xmipp_transform_geometry -i mD1.xmd --shift 2 3 4 --scale 1.2 --rotate 23 -o newGeo.xmd --apply_transform");
88 addExampleLine(
"To simply apply the transformations in a metadata to the images:",
false);
89 addExampleLine(
"xmipp_transform_geometry -i mD1.xmd --apply_transform");
90 addExampleLine(
"Shift a volume by 10, 5 and -10 in x,y and z and do not wrap",
false);
91 addExampleLine(
"xmipp_transform_geometry -i a.vol --shift 10 5 -10 -o b.vol --dont_wrap");
92 addExampleLine(
"Scale a group of images to half size, not modifying image dimensions neither original image files",
false);
93 addExampleLine(
"xmipp_transform_geometry -i images.xmd --scale 0.5 -o halvedOriginal.xmd");
104 if (degree ==
"spline")
106 else if (degree ==
"linear")
130 const char * rotateType =
getParam(
"--rotate_volume");
132 if (!
STR_EQUAL(rotateType,
"icosahedral"))
141 else if (
STR_EQUAL(rotateType,
"matrix"))
145 for (
int i = 0;
i < 9; ++
i)
152 else if (
STR_EQUAL(rotateType,
"alignZ"))
154 else if (
STR_EQUAL(rotateType,
"icosahedral"))
156 const char * icoFrom =
getParam(
"--rotate_volume", 1);
157 const char * icoTo =
getParam(
"--rotate_volume", 2);
236 std::cerr <<
T << std::endl;
244 double rot, tilt,
psi;
275 img().setXmippOrigin();
278 imgOut().setXmippOrigin();
286 if (fnImg != fnImgOut )
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 resize(int Xdim, int Ydim, int Zdim, size_t Ndim, bool copy=true)
double getDoubleParam(const char *param, int arg=0)
FileName replaceExtension(const String &newExt) const
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
void setValue(const MDObject &object) override
void inv(Matrix2D< T > &result) const
DataType getDatatype() const
void addKeywords(const char *keywords)
#define MAT_ELEM(m, i, j)
T & getValue(MDLabel label)
const char * getParam(const char *param, int arg=0)
void addExampleLine(const char *example, bool verbatim=true)
virtual void resetGeo(bool addLabels=true)
#define STR_EQUAL(str1, str2)
void setValue(MDLabel label, const T &d, bool addLabel=true)
void setDatatype(DataType _datatype)
double psi(const double x)
bool checkParam(const char *param)
void addUsageLine(const char *line, bool verbatim=false)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false)
bool hasMetadataExtension() const
void addParamsLine(const String &line)