#include <processor.h>
Inheritance diagram for EMAN::ClampingProcessor:
Public Member Functions | |
ClampingProcessor () | |
string | get_name () const |
Get the processor's name. | |
void | process_inplace (EMData *image) |
To process an image in-place. | |
TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "threshold.clampminmax" |
Protected Attributes | |
float | default_max |
float | default_min |
minval | the minimum value to clamp to | |
maxval | the maximum value to clamp to Replace outlying pixels values with the mean pixel value instead |
Definition at line 1699 of file processor.h.
EMAN::ClampingProcessor::ClampingProcessor | ( | ) | [inline] |
Definition at line 1702 of file processor.h.
Referenced by NEW().
01702 : default_max(1.0), default_min(0.0) {}
string EMAN::ClampingProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Reimplemented in EMAN::NSigmaClampingProcessor.
Definition at line 1724 of file processor.h.
01725 { 01726 return "This function clamps the min and max vals in the image at minval and maxval, respectively. In a sense this a bi-truncation of the data."; 01727 }
string EMAN::ClampingProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Reimplemented in EMAN::NSigmaClampingProcessor.
Definition at line 1704 of file processor.h.
References NAME.
01705 { 01706 return NAME; 01707 }
TypeDict EMAN::ClampingProcessor::get_param_types | ( | ) | const [inline, virtual] |
Get processor parameter information in a dictionary.
Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor.
Reimplemented in EMAN::NSigmaClampingProcessor.
Definition at line 1715 of file processor.h.
References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
01716 { 01717 TypeDict d; 01718 d.put("minval", EMObject::FLOAT, "The pixel values that bounds the smallest pixel value in the output image" ); 01719 d.put("maxval", EMObject::FLOAT, "The pixel values that bounds the largest pixel value in the output image" ); 01720 d.put("tomean", EMObject::BOOL, "Replace outlying pixels values with the mean pixel value instead" ); 01721 return d; 01722 }
static Processor* EMAN::ClampingProcessor::NEW | ( | ) | [inline, static] |
Reimplemented in EMAN::NSigmaClampingProcessor.
Definition at line 1708 of file processor.h.
References ClampingProcessor().
01709 { 01710 return new ClampingProcessor(); 01711 }
void ClampingProcessor::process_inplace | ( | EMData * | image | ) | [virtual] |
To process an image in-place.
For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.
image | The image to be processed. |
Implements EMAN::Processor.
Reimplemented in EMAN::NSigmaClampingProcessor.
Definition at line 8754 of file processor.cpp.
References default_max, default_min, EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_size(), ImageFormatException, InvalidParameterException, EMAN::EMData::is_complex(), max, min, EMAN::Processor::params, EMAN::Dict::set_default(), and EMAN::EMData::update().
08755 { 08756 08757 if ( image->is_complex() ) throw ImageFormatException("Error: clamping processor does not work on complex images"); 08758 08759 float min = params.set_default("minval",default_min); 08760 float max = params.set_default("maxval",default_max); 08761 bool tomean = params.set_default("tomean",false); 08762 float new_min_vals = min; 08763 float new_max_vals = max; 08764 if (tomean){ 08765 08766 new_min_vals = image->get_attr("mean"); 08767 new_max_vals = image->get_attr("mean"); 08768 } 08769 08770 // Okay, throwing such an error is probably overkill - but atleast the user will get a loud message 08771 // saying what went wrong. 08772 if ( max < min ) throw InvalidParameterException("Error: minval was greater than maxval, aborting"); 08773 08774 size_t size = image->get_size(); 08775 for(size_t i = 0; i < size; ++i ) 08776 { 08777 float * data = &image->get_data()[i]; 08778 if ( *data < min ) *data = new_min_vals; 08779 else if ( *data > max ) *data = new_max_vals; 08780 } 08781 image->update(); 08782 }
float EMAN::ClampingProcessor::default_max [protected] |
float EMAN::ClampingProcessor::default_min [protected] |
const string ClampingProcessor::NAME = "threshold.clampminmax" [static] |
Reimplemented in EMAN::NSigmaClampingProcessor.
Definition at line 1729 of file processor.h.
Referenced by get_name().