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

EMAN::SmartMaskProcessor Class Reference

Smart mask processor. More...

#include <processor.h>

Inheritance diagram for EMAN::SmartMaskProcessor:

[legend]
Collaboration diagram for EMAN::SmartMaskProcessor:
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual string get_desc () const
 Get the descrition of this specific processor.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "mask.smart"

Detailed Description

Smart mask processor.

Parameters:
mask mask value

Definition at line 5696 of file processor.h.


Member Function Documentation

virtual string EMAN::SmartMaskProcessor::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.

Definition at line 5711 of file processor.h.

05712                 {
05713                         return "Smart mask processor.";
05714                 }

virtual string EMAN::SmartMaskProcessor::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.

Definition at line 5701 of file processor.h.

05702                 {
05703                         return NAME;
05704                 }

virtual TypeDict EMAN::SmartMaskProcessor::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.

Definition at line 5716 of file processor.h.

References EMAN::TypeDict::put().

05717                 {
05718                         TypeDict d;
05719                         d.put("mask", EMObject::FLOAT, "mask value");
05720                         return d;
05721                 }

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

Definition at line 5706 of file processor.h.

05707                 {
05708                         return new SmartMaskProcessor();
05709                 }

void SmartMaskProcessor::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.

Definition at line 6070 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, sqrt(), and EMAN::EMData::update().

06071 {
06072         if (!image) {
06073                 LOGWARN("NULL Image");
06074                 return;
06075         }
06076 
06077         float mask = params["mask"];
06078 
06079         int nx = image->get_xsize();
06080         int ny = image->get_ysize();
06081         int nz = image->get_zsize();
06082 
06083         float *dat = image->get_data();
06084         double sma = 0;
06085         int smn = 0;
06086         float r = 0.0f;
06087         for (int k = 0; k < nz; ++k) {
06088                 for (int j = 0; j < ny; ++j) {
06089                         for (int i = 0; i < nx; ++i, ++dat) {
06090                                 r =
06091                                         sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
06092                                                  Util::square(k - nz / 2));
06093                                 if (r > mask - 1.5f && r < mask - 0.5f) {
06094                                         sma += *dat;
06095                                         smn++;
06096                                 }
06097                         }
06098                 }
06099         }
06100 
06101         float smask = (float) sma / smn;
06102         image->update();
06103 
06104         dat = image->get_data();
06105         for (int k = 0; k < nz; ++k) {
06106                 for (int j = 0; j < ny; ++j) {
06107                         for (int i = 0; i < nx; ++i, ++dat) {
06108                                 r =
06109                                         sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
06110                                                  Util::square(k - nz / 2));
06111                                 if (r > mask - .5) {
06112                                         *dat = 0;
06113                                 }
06114                                 else {
06115                                         *dat -= smask;
06116                                 }
06117                         }
06118                 }
06119         }
06120 
06121         image->update();
06122 }


Member Data Documentation

const string SmartMaskProcessor::NAME = "mask.smart" [static]
 

Definition at line 188 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:27 2010 for EMAN2 by  doxygen 1.3.9.1