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:

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

Collaboration graph
[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 5781 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 5796 of file processor.h.

05797                 {
05798                         return "Smart mask processor.";
05799                 }

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

05787                 {
05788                         return NAME;
05789                 }

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

References EMAN::TypeDict::put().

05802                 {
05803                         TypeDict d;
05804                         d.put("mask", EMObject::FLOAT, "mask value");
05805                         return d;
05806                 }

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

Definition at line 5791 of file processor.h.

05792                 {
05793                         return new SmartMaskProcessor();
05794                 }

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

06333 {
06334         if (!image) {
06335                 LOGWARN("NULL Image");
06336                 return;
06337         }
06338 
06339         float mask = params["mask"];
06340 
06341         int nx = image->get_xsize();
06342         int ny = image->get_ysize();
06343         int nz = image->get_zsize();
06344 
06345         float *dat = image->get_data();
06346         double sma = 0;
06347         size_t smn = 0;
06348         float r = 0.0f;
06349         for (int k = 0; k < nz; ++k) {
06350                 for (int j = 0; j < ny; ++j) {
06351                         for (int i = 0; i < nx; ++i, ++dat) {
06352                                 r =
06353                                         sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
06354                                                  Util::square(k - nz / 2));
06355                                 if (r > mask - 1.5f && r < mask - 0.5f) {
06356                                         sma += *dat;
06357                                         smn++;
06358                                 }
06359                         }
06360                 }
06361         }
06362 
06363         float smask = (float) (sma / smn);
06364         image->update();
06365 
06366         dat = image->get_data();
06367         for (int k = 0; k < nz; ++k) {
06368                 for (int j = 0; j < ny; ++j) {
06369                         for (int i = 0; i < nx; ++i, ++dat) {
06370                                 r =
06371                                         sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
06372                                                  Util::square(k - nz / 2));
06373                                 if (r > mask - .5) {
06374                                         *dat = 0;
06375                                 }
06376                                 else {
06377                                         *dat -= smask;
06378                                 }
06379                         }
06380                 }
06381         }
06382 
06383         image->update();
06384 }


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 Aug 10 16:37:32 2012 for EMAN2 by  doxygen 1.3.9.1