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

05107                 {
05108                         return "Add additional shells/rings to an existing 1/0 mask image";
05109                 }

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

References NAME.

05102                 {
05103                         return NAME;
05104                 }

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

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

05117                 {
05118                         TypeDict d;
05119                         d.put("nshells", EMObject::INT, "number of shells to add");
05120                         return d;
05121                 }

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

Definition at line 5111 of file processor.h.

05112                 {
05113                         return new AddMaskShellProcessor();
05114                 }

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

05658 {
05659         if (!image) {
05660                 LOGWARN("NULL Image");
05661                 return;
05662         }
05663 
05664         int nx = image->get_xsize();
05665         int ny = image->get_ysize();
05666         int nz = image->get_zsize();
05667 
05668         if (ny == 1) {
05669                 LOGERR("Tried to add mask shell to 1d image");
05670                 return;
05671         }
05672 
05673         int num_shells = params["nshells"];
05674 
05675         float *d = image->get_data();
05676         float k = 0.99999f;
05677         int nxy = nx * ny;
05678 
05679         if (nz == 1) {
05680                 for (int i = 0; i < num_shells; i++) {
05681                         for (int y = 1; y < ny - 1; y++) {
05682                                 int cur_y = y * nx;
05683 
05684                                 for (int x = 1; x < nx - 1; x++) {
05685                                         int j = x + cur_y;
05686                                         if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
05687                                                 d[j] = k;
05688                                         }
05689                                 }
05690                         }
05691                         k -= 0.00001f;
05692                 }
05693         }
05694         else {
05695                 for (int i = 0; i < num_shells; i++) {
05696                         for (int z = 1; z < nz - 1; z++) {
05697                                 size_t cur_z = (size_t)z * nx * ny;
05698 
05699                                 for (int y = 1; y < ny - 1; y++) {
05700                                         size_t cur_y = y * nx + cur_z;
05701 
05702                                         for (int x = 1; x < nx - 1; x++) {
05703                                                 size_t j = x + cur_y;
05704 
05705                                                 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
05706                                                                           d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
05707                                                         d[j] = k;
05708                                                 }
05709                                         }
05710                                 }
05711                         }
05712 
05713                         k -= 0.00001f;
05714                 }
05715         }
05716 
05717         size_t size = (size_t)nx * ny * nz;
05718         for (size_t i = 0; i < size; ++i) {
05719                 if (d[i]) {
05720                         d[i] = 1;
05721                 }
05722                 else {
05723                         d[i] = 0;
05724                 }
05725         }
05726 
05727         image->update();
05728 }


Member Data Documentation

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

Definition at line 5123 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:36 2012 for EMAN2 by  doxygen 1.4.7