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

Public Attributes

Image< double > Im
 
double min_val
 min_val. More...
 
double max_val
 max_val. More...
 
double sigma
 noise in %. More...
 
Mask mask_prm
 Mask. More...
 
- Public Attributes inherited from XmippMetadataProgram
FileName fn_in
 Filenames of input and output Metadata. More...
 
FileName fn_out
 
FileName baseName
 
FileName pathBaseName
 
FileName oextBaseName
 
bool apply_geo
 Apply geo. More...
 
size_t ndimOut
 Output dimensions. More...
 
size_t zdimOut
 
size_t ydimOut
 
size_t xdimOut
 
DataType datatypeOut
 
size_t mdInSize
 Number of input elements. More...
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Protected Member Functions

void defineParams ()
 
void readParams ()
 
void show ()
 
void processImage (const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
 
- Protected Member Functions inherited from XmippMetadataProgram
virtual void initComments ()
 
virtual void preProcess ()
 
virtual void postProcess ()
 
virtual bool getImageToProcess (size_t &objId, size_t &objIndex)
 
void show () const override
 
virtual void startProcessing ()
 
virtual void finishProcessing ()
 
virtual void writeOutput ()
 
virtual void showProgress ()
 
virtual void defineLabelParam ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 

Additional Inherited Members

- Public Member Functions inherited from XmippMetadataProgram
MetaDatagetInputMd ()
 
MetaDataVecgetOutputMd ()
 
 XmippMetadataProgram ()
 Empty constructor. More...
 
virtual int tryRead (int argc, const char **argv, bool reportErrors=true)
 
virtual void init ()
 
virtual void setup (MetaData *md, const FileName &o="", const FileName &oroot="", bool applyGeo=false, MDLabel label=MDL_IMAGE)
 
virtual ~XmippMetadataProgram ()
 
void setMode (WriteModeMetaData _mode)
 
void setupRowOut (const FileName &fnImgIn, const MDRow &rowIn, const FileName &fnImgOut, MDRow &rowOut) const
 Prepare rowout. More...
 
virtual void wait ()
 Wait for the distributor to finish. More...
 
virtual void checkPoint ()
 For very long programs, it may be needed to write checkpoints. More...
 
virtual void run ()
 Run over all images. 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)
 
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 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 ()
 
- Protected Attributes inherited from XmippMetadataProgram
WriteModeMetaData mode
 Metadata writing mode: OVERWRITE, APPEND. More...
 
FileName oext
 Output extension and root. More...
 
FileName oroot
 
MDLabel image_label
 MDLabel to be used to read/write images, usually will be MDL_IMAGE. More...
 
bool produces_an_output
 Indicate that a unique final output is produced. More...
 
bool produces_a_metadata
 Indicate that the unique final output file is a Metadata. More...
 
bool each_image_produces_an_output
 Indicate that an output is produced for each image in the input. More...
 
bool allow_apply_geo
 
bool decompose_stacks
 Input Metadata will treat a stack file as a set of images instead of a unique file. More...
 
bool delete_output_stack
 Delete previous output stack file prior to process images. More...
 
bool get_image_info
 Get the input image file dimensions to further operations. More...
 
bool save_metadata_stack
 Save the associated output metadata when output file is a stack. More...
 
bool track_origin
 Include the original input image filename in the output stack. More...
 
bool keep_input_columns
 Keep input metadata columns. More...
 
bool remove_disabled
 Remove disabled images from the input selfile. More...
 
bool allow_time_bar
 Show process time bar. More...
 
bool input_is_metadata
 Input is a metadata. More...
 
bool single_image
 Input is a single image. More...
 
bool input_is_stack
 Input is a stack. More...
 
bool output_is_stack
 Output is a stack. More...
 
bool create_empty_stackfile
 
bool delete_mdIn
 
size_t time_bar_step
 Some time bar related counters. More...
 
size_t time_bar_size
 
size_t time_bar_done
 
- 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 30 of file transform_range_adjust.cpp.

Member Function Documentation

◆ defineParams()

void ProgTransRangeAdjust::defineParams ( )
inlineprotectedvirtual

Function in which the param of each Program are defined.

Reimplemented from XmippMetadataProgram.

Definition at line 49 of file transform_range_adjust.cpp.

50  {
52 
53  addUsageLine("Adjust the grey level value of the pixels to a specified range.");
54  addKeywords("mask, normalization");
55  addSeeAlsoLine("transform_normalize");
57  addParamsLine(" --range <min_val> <max_val> : Output minimum and maximum values.");
58  addParamsLine(" alias -r;");
59  addParamsLine(" [--noise <sigma=0>] : Variation of the limit range values.");
60  mask_prm.defineParams(this,INT_MASK, nullptr, "Pixels in the mask area are guaranteed to be into the specified range.");
61 
62  addExampleLine("Adjust an image in the range [-1, 1]:", false);
63  addExampleLine("xmipp_transform_range_adjust -i image.xmp -o image_adjust.xmp --range -1 1");
64  addExampleLine("Adjust images in a stack applying a circular mask:", false);
65  addExampleLine("xmipp_transform_range_adjust -i images.stk -o image_adjust.stk --range -1 1 --mask circular -32");
66  addExampleLine("Adjust a selection file in the range [-100, 100] with sigma noise 10:", false);
67  addExampleLine("xmipp_transform_range_adjust -i selection.sel --oroot images/im_adjust:spi -o selection_adjust.sel --range -100 100 --noise 10");
68  }
void addSeeAlsoLine(const char *seeAlso)
static void defineParams(XmippProgram *program, int allowed_data_types=ALL_KINDS, const char *prefix=nullptr, const char *comment=nullptr, bool moreOptions=false)
Definition: mask.cpp:1203
void addKeywords(const char *keywords)
void addExampleLine(const char *example, bool verbatim=true)
#define INT_MASK
Definition: mask.h:385
bool each_image_produces_an_output
Indicate that an output is produced for each image in the input.
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ processImage()

void ProgTransRangeAdjust::processImage ( const FileName fnImg,
const FileName fnImgOut,
const MDRow rowIn,
MDRow rowOut 
)
inlineprotectedvirtual

Implements XmippMetadataProgram.

Definition at line 96 of file transform_range_adjust.cpp.

97  {
98  double amin = rnd_gaus(0, sigma);
99  double amax = rnd_gaus(0, sigma);
100  double minval = min_val + amin;
101  double maxval = max_val + amax;
102 
103  Im.read(fnImg);
104  MultidimArray<double> &ImP = Im();
105  ImP.setXmippOrigin();
106 
107  if (mask_prm.type == NO_MASK)
108  ImP.rangeAdjust(minval, maxval);
109  else
110  {
111  mask_prm.generate_mask(ImP);
112  ImP.rangeAdjust(minval, maxval,mask_prm.get_binary_mask());
113  }
114 
115  Im.write(fnImgOut);
116  }
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 rangeAdjust(T minF, T maxF)
#define NO_MASK
Definition: mask.h:364
int type
Definition: mask.h:402
void generate_mask(bool apply_geo=false)
Definition: mask.cpp:1577
double rnd_gaus()
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
const MultidimArray< int > & get_binary_mask() const
Definition: mask.h:707

◆ readParams()

void ProgTransRangeAdjust::readParams ( )
inlineprotectedvirtual

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

Reimplemented from XmippMetadataProgram.

Definition at line 70 of file transform_range_adjust.cpp.

71  {
73 
74  min_val = getDoubleParam("--range", 0);
75  max_val = getDoubleParam("--range", 1);
76  sigma = getDoubleParam("--noise");
78 
79  if (checkParam("--mask"))
80  {
82  mask_prm.readParams(this);
83  }
84  }
double getDoubleParam(const char *param, int arg=0)
int allowed_data_types
Definition: mask.h:495
void readParams(XmippProgram *program)
Definition: mask.cpp:1284
#define INT_MASK
Definition: mask.h:385
bool checkParam(const char *param)
unsigned int randomize_random_generator()

◆ show()

void ProgTransRangeAdjust::show ( )
inlineprotected

Definition at line 86 of file transform_range_adjust.cpp.

87  {
89  if (verbose==0)
90  return;
91  std::cout << "Min: " << min_val << std::endl
92  << "Max: " << max_val << std::endl
93  << "Noise: " << sigma << std::endl;
94  }
int verbose
Verbosity level.
void show() const override

Member Data Documentation

◆ Im

Image<double> ProgTransRangeAdjust::Im

Definition at line 34 of file transform_range_adjust.cpp.

◆ mask_prm

Mask ProgTransRangeAdjust::mask_prm

Mask.

Definition at line 45 of file transform_range_adjust.cpp.

◆ max_val

double ProgTransRangeAdjust::max_val

max_val.

Definition at line 39 of file transform_range_adjust.cpp.

◆ min_val

double ProgTransRangeAdjust::min_val

min_val.

Definition at line 36 of file transform_range_adjust.cpp.

◆ sigma

double ProgTransRangeAdjust::sigma

noise in %.

Definition at line 42 of file transform_range_adjust.cpp.


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