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

05031                 {
05032                         return "Add additional shells/rings to an existing 1/0 mask image";
05033                 }

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

References NAME.

05026                 {
05027                         return NAME;
05028                 }

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

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

05041                 {
05042                         TypeDict d;
05043                         d.put("nshells", EMObject::INT, "number of shells to add");
05044                         return d;
05045                 }

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

Definition at line 5035 of file processor.h.

05036                 {
05037                         return new AddMaskShellProcessor();
05038                 }

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 5499 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.

05500 {
05501         if (!image) {
05502                 LOGWARN("NULL Image");
05503                 return;
05504         }
05505 
05506         int nx = image->get_xsize();
05507         int ny = image->get_ysize();
05508         int nz = image->get_zsize();
05509 
05510         if (ny == 1) {
05511                 LOGERR("Tried to add mask shell to 1d image");
05512                 return;
05513         }
05514 
05515         int num_shells = params["nshells"];
05516 
05517         float *d = image->get_data();
05518         float k = 0.99999f;
05519         int nxy = nx * ny;
05520 
05521         if (nz == 1) {
05522                 for (int i = 0; i < num_shells; i++) {
05523                         for (int y = 1; y < ny - 1; y++) {
05524                                 int cur_y = y * nx;
05525 
05526                                 for (int x = 1; x < nx - 1; x++) {
05527                                         int j = x + cur_y;
05528                                         if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
05529                                                 d[j] = k;
05530                                         }
05531                                 }
05532                         }
05533                         k -= 0.00001f;
05534                 }
05535         }
05536         else {
05537                 for (int i = 0; i < num_shells; i++) {
05538                         for (int z = 1; z < nz - 1; z++) {
05539                                 size_t cur_z = (size_t)z * nx * ny;
05540 
05541                                 for (int y = 1; y < ny - 1; y++) {
05542                                         size_t cur_y = y * nx + cur_z;
05543 
05544                                         for (int x = 1; x < nx - 1; x++) {
05545                                                 size_t j = x + cur_y;
05546 
05547                                                 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
05548                                                                           d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
05549                                                         d[j] = k;
05550                                                 }
05551                                         }
05552                                 }
05553                         }
05554 
05555                         k -= 0.00001f;
05556                 }
05557         }
05558 
05559         size_t size = (size_t)nx * ny * nz;
05560         for (size_t i = 0; i < size; ++i) {
05561                 if (d[i]) {
05562                         d[i] = 1;
05563                 }
05564                 else {
05565                         d[i] = 0;
05566                 }
05567         }
05568 
05569         image->update();
05570 }


Member Data Documentation

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

Definition at line 5047 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:49:26 2011 for EMAN2 by  doxygen 1.4.7