Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

ProcessorNEW ()

Static Public Attributes

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:
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 1709 of file processor.h.


Constructor & Destructor Documentation

EMAN::ClampingProcessor::ClampingProcessor  )  [inline]
 

Definition at line 1712 of file processor.h.

01712 : 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 1734 of file processor.h.

01735                 {
01736                         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.";
01737                 }

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 1714 of file processor.h.

01715                 {
01716                         return NAME;
01717                 }

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 1725 of file processor.h.

References EMAN::TypeDict::put().

01726                 {
01727                         TypeDict d;
01728                         d.put("minval", EMObject::FLOAT, "The pixel values that bounds the smallest pixel value in the output image" );
01729                         d.put("maxval", EMObject::FLOAT, "The pixel values that bounds the largest pixel value in the output image" );
01730                         d.put("tomean", EMObject::BOOL, "Replace outlying pixels values with the mean pixel value instead" );
01731                         return d;
01732                 }

Processor* EMAN::ClampingProcessor::NEW  )  [inline, static]
 

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 1718 of file processor.h.

01719                 {
01720                         return new ClampingProcessor();
01721                 }

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:
image The image to be processed.

Implements EMAN::Processor.

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 8914 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().

08915 {
08916 
08917         if ( image->is_complex() ) throw ImageFormatException("Error: clamping processor does not work on complex images");
08918 
08919         float min = params.set_default("minval",default_min);
08920         float max = params.set_default("maxval",default_max);
08921         bool tomean = params.set_default("tomean",false);
08922         float new_min_vals = min;
08923         float new_max_vals = max;
08924         if (tomean){
08925 
08926                 new_min_vals = image->get_attr("mean");
08927                 new_max_vals = image->get_attr("mean");
08928         }
08929 
08930         // Okay, throwing such an error is probably overkill - but atleast the user will get a loud message
08931         // saying what went wrong.
08932         if ( max < min ) throw InvalidParameterException("Error: minval was greater than maxval, aborting");
08933 
08934         size_t size = image->get_size();
08935         for(size_t i = 0; i < size; ++i )
08936         {
08937                 float * data = &image->get_data()[i];
08938                 if ( *data < min ) *data = new_min_vals;
08939                 else if ( *data > max ) *data = new_max_vals;
08940         }
08941         image->update();
08942 }


Member Data Documentation

float EMAN::ClampingProcessor::default_max [protected]
 

Definition at line 1742 of file processor.h.

Referenced by process_inplace().

float EMAN::ClampingProcessor::default_min [protected]
 

Definition at line 1742 of file processor.h.

Referenced by process_inplace().

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

Reimplemented in EMAN::NSigmaClampingProcessor.

Definition at line 90 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon Aug 13 13:42:00 2012 for EMAN2 by  doxygen 1.3.9.1