EMAN::AddMaskShellProcessor Class Reference

Add additional shells/rings to an existing 1/0 mask image. More...

#include <processor.h>

Inheritance diagram for EMAN::AddMaskShellProcessor:

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

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.addshells"

Detailed Description

Add additional shells/rings to an existing 1/0 mask image.

Parameters:
nshells number of shells to add

Definition at line 5057 of file processor.h.


Member Function Documentation

virtual string EMAN::AddMaskShellProcessor::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 5067 of file processor.h.

05068                 {
05069                         return "Add additional shells/rings to an existing 1/0 mask image";
05070                 }

virtual string EMAN::AddMaskShellProcessor::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 5062 of file processor.h.

References NAME.

05063                 {
05064                         return NAME;
05065                 }

virtual TypeDict EMAN::AddMaskShellProcessor::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 5077 of file processor.h.

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

05078                 {
05079                         TypeDict d;
05080                         d.put("nshells", EMObject::INT, "number of shells to add");
05081                         return d;
05082                 }

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

Definition at line 5072 of file processor.h.

05073                 {
05074                         return new AddMaskShellProcessor();
05075                 }

void AddMaskShellProcessor::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 5548 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGERR, LOGWARN, EMAN::Processor::params, EMAN::EMData::update(), and x.

05549 {
05550         if (!image) {
05551                 LOGWARN("NULL Image");
05552                 return;
05553         }
05554 
05555         int nx = image->get_xsize();
05556         int ny = image->get_ysize();
05557         int nz = image->get_zsize();
05558 
05559         if (ny == 1) {
05560                 LOGERR("Tried to add mask shell to 1d image");
05561                 return;
05562         }
05563 
05564         int num_shells = params["nshells"];
05565 
05566         float *d = image->get_data();
05567         float k = 0.99999f;
05568         int nxy = nx * ny;
05569 
05570         if (nz == 1) {
05571                 for (int i = 0; i < num_shells; i++) {
05572                         for (int y = 1; y < ny - 1; y++) {
05573                                 int cur_y = y * nx;
05574 
05575                                 for (int x = 1; x < nx - 1; x++) {
05576                                         int j = x + cur_y;
05577                                         if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
05578                                                 d[j] = k;
05579                                         }
05580                                 }
05581                         }
05582                         k -= 0.00001f;
05583                 }
05584         }
05585         else {
05586                 for (int i = 0; i < num_shells; i++) {
05587                         for (int z = 1; z < nz - 1; z++) {
05588                                 size_t cur_z = z * nx * ny;
05589 
05590                                 for (int y = 1; y < ny - 1; y++) {
05591                                         size_t cur_y = y * nx + cur_z;
05592 
05593                                         for (int x = 1; x < nx - 1; x++) {
05594                                                 size_t j = x + cur_y;
05595 
05596                                                 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
05597                                                                           d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
05598                                                         d[j] = k;
05599                                                 }
05600                                         }
05601                                 }
05602                         }
05603 
05604                         k -= 0.00001f;
05605                 }
05606         }
05607 
05608         size_t size = nx * ny * nz;
05609         for (size_t i = 0; i < size; i++) {
05610                 if (d[i]) {
05611                         d[i] = 1;
05612                 }
05613                 else {
05614                         d[i] = 0;
05615                 }
05616         }
05617 
05618         image->update();
05619 }


Member Data Documentation

const string AddMaskShellProcessor::NAME = "mask.addshells" [static]

Definition at line 5084 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:43:54 2010 for EMAN2 by  doxygen 1.4.7