EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
EMAN::ClampingProcessor Class Reference

f(x) = maxval if f(x) > maxval; f(x) = minval if f(x) < minval More...

#include <processor.h>

Inheritance diagram for EMAN::ClampingProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::ClampingProcessor:
Collaboration graph
[legend]

List of all members.

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 ProcessorNEW ()

Static Public Attributes

static const string NAME = "threshold.clampminmax"

Protected Attributes

float default_max
float default_min

Detailed Description

f(x) = maxval if f(x) > maxval; f(x) = minval if f(x) < minval

Parameters:
minvalthe minimum value to clamp to
maxvalthe maximum value to clamp to Replace outlying pixels values with the mean pixel value instead

Definition at line 1842 of file processor.h.


Constructor & Destructor Documentation

EMAN::ClampingProcessor::ClampingProcessor ( ) [inline]

Definition at line 1845 of file processor.h.

Referenced by NEW().

: default_max(1.0), default_min(0.0) {}

Member Function Documentation

string EMAN::ClampingProcessor::get_desc ( ) const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 1868 of file processor.h.

                {
                        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.";
                }
string EMAN::ClampingProcessor::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 1847 of file processor.h.

References NAME.

                {
                        return NAME;
                }
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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 1858 of file processor.h.

References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

                {
                        TypeDict d;
                        d.put("minval", EMObject::FLOAT, "The pixel values that bounds the smallest pixel value in the output image" );
                        d.put("maxval", EMObject::FLOAT, "The pixel values that bounds the largest pixel value in the output image" );
                        d.put("tomean", EMObject::BOOL, "Replace outlying pixels values with the mean pixel value instead" );
                        d.put("tozero", EMObject::BOOL, "Replace outlying pixels values with zero" );
                        return d;
                }
static Processor* EMAN::ClampingProcessor::NEW ( ) [inline, static]

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 1851 of file processor.h.

References ClampingProcessor().

                {
                        return new ClampingProcessor();
                }
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.

Parameters:
imageThe image to be processed.

Implements EMAN::Processor.

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 9613 of file processor.cpp.

References 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().

{

        if ( image->is_complex() ) throw ImageFormatException("Error: clamping processor does not work on complex images");

        float min = params.set_default("minval",default_min);
        float max = params.set_default("maxval",default_max);
        bool tomean = params.set_default("tomean",false);
        bool tozero = params.set_default("tozero",false);
        float new_min_vals = min;
        float new_max_vals = max;
        if (tomean) new_min_vals = new_max_vals = image->get_attr("mean");
        if (tozero) new_min_vals = new_max_vals = 0.0;

        // Okay, throwing such an error is probably overkill - but atleast the user will get a loud message
        // saying what went wrong.
        if ( max < min ) throw InvalidParameterException("Error: minval was greater than maxval, aborting");

        size_t size = image->get_size();
        for(size_t i = 0; i < size; ++i )
        {
                float * data = &image->get_data()[i];
                if ( *data < min ) *data = new_min_vals;
                else if ( *data > max ) *data = new_max_vals;
        }
        image->update();
}

Member Data Documentation

Definition at line 1876 of file processor.h.

Definition at line 1876 of file processor.h.

const string ClampingProcessor::NAME = "threshold.clampminmax" [static]

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 1873 of file processor.h.

Referenced by get_name().


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