26 #ifndef _CORE_XMIPPMICROGRAPH_H 27 #define _CORE_XMIPPMICROGRAPH_H 100 bool compute_transmitance;
101 bool compute_inverse;
103 std::vector<std::string> labels;
104 double stdevFilter = -1;
129 int getDatatypeDetph()
const;
133 void open_micrograph(
const FileName &fn_micrograph);
137 void close_micrograph();
142 return fn_micrograph;
171 void write_coordinates(
int label,
double minCost,
const FileName &fn_coords =
"");
177 void read_coordinates(
int label,
const FileName &fn_coords);
184 void scale_coordinates(
const double &
c);
190 return coords.size();
211 X_window_size = _X_window_size;
212 Y_window_size = _Y_window_size;
222 compute_transmitance =
228 datatype = _datatype;
237 return compute_transmitance;
256 return compute_inverse;
262 template <
typename T>
265 double Dmin,
double Dmax,
double scaleX,
double scaleY,
266 bool only_check,
bool fillBorders)
268 result.
initZeros(Y_window_size, X_window_size);
274 double irange=1.0/(Dmax - Dmin);
276 if (!fillBorders && (_i0 < 0 || _iF >= Ydim || _j0 < 0 || _jF >= Xdim))
282 for (
int i = _i0, i_i0=0;
i <= _iF;
i++, i_i0++)
289 else if (ifrom>=Ydim)
292 for (
int j=_j0, j_j0=0;
j<=_jF;
j++, j_j0++)
299 else if (jfrom>=Xdim)
303 if (compute_transmitance)
311 A2D_ELEM(result,i_i0, j_j0) = (Dmax - temp) * irange;
313 A2D_ELEM(result,i_i0, j_j0) = (temp - Dmin) * irange;
318 A2D_ELEM(result, i_i0, j_j0) = (Dmax - val) * irange;
347 double Dmin,
double Dmax,
348 double scaleX = 1,
double scaleY = 1,
bool only_check =
false,
349 bool fillBorders =
false);
356 if (y < 0 || y >= Ydim || x < 0 || x >= Xdim)
375 else if (datatype ==
DT_Int)
392 return IUChar().computeDoubleMinMax(Dmin,Dmax);
396 return IUShort().computeDoubleMinMax(Dmin,Dmax);
400 return IShort().computeDoubleMinMax(Dmin,Dmax);
404 return IUInt().computeDoubleMinMax(Dmin,Dmax);
406 else if (datatype ==
DT_Int)
408 return IInt().computeDoubleMinMax(Dmin,Dmax);
412 return IFloat().computeDoubleMinMax(Dmin,Dmax);
426 IMGPIXEL(IUChar,y,x) = (
unsigned char) new_val;
430 IMGPIXEL(IUShort,y,x) = (
unsigned short) new_val;
434 IMGPIXEL(IShort,y,x) = (short) new_val;
438 IMGPIXEL(IUInt,y,x) = (
unsigned int) new_val;
440 else if (datatype ==
DT_Int)
446 IMGPIXEL(IFloat,y,x) = (float) new_val;
459 void produce_all_images(
int label,
double minCost,
const FileName &fn_root,
460 const FileName &fn_image =
"",
double ang = 0,
463 bool fillBorders=
false,
464 bool extractNoise=
false,
470 int search_coord_near(
int x,
int y,
int prec = 3)
const;
475 void invalidate_coord(
int n);
479 int add_coord(
int x,
int y,
int label,
double cost);
482 void move_last_coord_to(
int x,
int y);
488 if (n < 0 || n > ParticleNo())
503 labels.push_back(label);
504 return labels.size() - 1;
510 return labels.size();
518 if (n < 0 || n > LabelNo())
526 _label = get_label(n);
530 void size(
int &_Xdim,
int &_Ydim)
const 537 void resize(
int Xdim,
int Ydim,
const FileName &filename=
"");
563 void addCoordinatePair(
int _muX,
int _muY,
int _mtX,
int _mtY);
566 void adjustPassingMatrix(
int _muX,
int _muY,
int _mtX,
int _mtY);
569 void calculatePassingMatrix();
572 void passToTilted(
int _muX,
int _muY,
int &_mtX,
int &_mtY);
575 void passToUntilted(
int _mtX,
int _mtY,
int &_muX,
int &_muY);
583 void computeAngles(
double &ualpha,
double &talpha,
double &ogamma);
void set_ctfparams(const MDRowVec &ctf)
#define A2D_ELEM(v, i, j)
void write(std::ostream &os, const datablock &db)
#define REPORT_ERROR(nerr, ErrormMsg)
Matrix1D< double > m
Auxiliary vector.
bool read_transmitance_flag(void)
void setStdevFilter(double d)
std::vector< Particle_coords > coords
std::vector< Particle_coords > & Particles()
bool read_inverse_flag(void)
void set_window_size(int _X_window_size, int _Y_window_size)
void set_micrograph_name(const FileName &fn)
int add_label(const std::string &label)
double scoreVar
Score by var and Gini.
void get_coord(int n, Particle_coords &_coords)
void computeDoubleMinMax(double &Dmin, double &Dmax) const
double operator()(size_t y, size_t x) const
void get_Particles(std::vector< Particle_coords > &_coords)
const MDRow & get_ctfparams()
void set_val(int y, int x, double new_val)
int templateScissor(const Image< T > &I, const Particle_coords &P, MultidimArray< double > &result, double Dmin, double Dmax, double scaleX, double scaleY, bool only_check, bool fillBorders)
double scoreGini
Score by Gini.
std::vector< int > coordT
Tilted coordinates.
void get_label(int n, std::string &_label)
void log10(Image< double > &op)
Matrix2D< double > pair_E
std::vector< int > coordU
Untilted coordinates.
void setDataType(DataType _datatype)
#define FIRST_XMIPP_INDEX(size)
void set_transmitance_flag(bool flag_value)
std::string & get_label(int n)
Particle_coords & coord(int n)
double cost
Cost, scaled between 0 and 1.
const FileName & micrograph_name()
void initZeros(const MultidimArray< T1 > &op)
#define LAST_XMIPP_INDEX(size)
void set_inverse_flag(bool flag_value)
void size(int &_Xdim, int &_Ydim) const
#define IMGPIXEL(I, i, j)