#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 | |
| Processor * | NEW () |
Static Public Attributes | |
| 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 1630 of file processor.h.
|
|
Definition at line 1633 of file processor.h. 01633 : default_max(1.0), default_min(0.0) {}
|
|
|
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 1655 of file processor.h. 01656 {
01657 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.";
01658 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Reimplemented in EMAN::NSigmaClampingProcessor. Definition at line 1635 of file processor.h. 01636 {
01637 return NAME;
01638 }
|
|
|
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 1646 of file processor.h. References EMAN::TypeDict::put(). 01647 {
01648 TypeDict d;
01649 d.put("minval", EMObject::FLOAT, "The pixel values that bounds the smallest pixel value in the output image" );
01650 d.put("maxval", EMObject::FLOAT, "The pixel values that bounds the largest pixel value in the output image" );
01651 d.put("tomean", EMObject::BOOL, "Replace outlying pixels values with the mean pixel value instead" );
01652 return d;
01653 }
|
|
|
Reimplemented in EMAN::NSigmaClampingProcessor. Definition at line 1639 of file processor.h. 01640 {
01641 return new ClampingProcessor();
01642 }
|
|
|
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.
Implements EMAN::Processor. Reimplemented in EMAN::NSigmaClampingProcessor. Definition at line 8709 of file processor.cpp. References data, 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::Dict::set_default(), and EMAN::EMData::update(). 08710 {
08711
08712 if ( image->is_complex() ) throw ImageFormatException("Error: clamping processor does not work on complex images");
08713
08714 float min = params.set_default("minval",default_min);
08715 float max = params.set_default("maxval",default_max);
08716 bool tomean = params.set_default("tomean",false);
08717 float new_min_vals = min;
08718 float new_max_vals = max;
08719 if (tomean){
08720
08721 new_min_vals = image->get_attr("mean");
08722 new_max_vals = image->get_attr("mean");
08723 }
08724
08725 // Okay, throwing such an error is probably overkill - but atleast the user will get a loud message
08726 // saying what went wrong.
08727 if ( max < min ) throw InvalidParameterException("Error: minval was greater than maxval, aborting");
08728
08729 size_t size = image->get_size();
08730 for(size_t i = 0; i < size; ++i )
08731 {
08732 float * data = &image->get_data()[i];
08733 if ( *data < min ) *data = new_min_vals;
08734 else if ( *data > max ) *data = new_max_vals;
08735 }
08736 image->update();
08737 }
|
|
|
Definition at line 1663 of file processor.h. Referenced by process_inplace(). |
|
|
Definition at line 1663 of file processor.h. Referenced by process_inplace(). |
|
|
Reimplemented in EMAN::NSigmaClampingProcessor. Definition at line 90 of file processor.cpp. |
1.3.9.1