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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "mask.smart"

Detailed Description

Smart mask processor.

Parameters:
mask mask value

Definition at line 5779 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 5794 of file processor.h.

05795                 {
05796                         return "Smart mask processor.";
05797                 }

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

References NAME.

05785                 {
05786                         return NAME;
05787                 }

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

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

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

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

Definition at line 5789 of file processor.h.

05790                 {
05791                         return new SmartMaskProcessor();
05792                 }

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 6322 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, sqrt(), EMAN::Util::square(), and EMAN::EMData::update().

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


Member Data Documentation

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

Definition at line 5806 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:10:44 2012 for EMAN2 by  doxygen 1.4.7