Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

ProcessorNEW ()

Static Public Attributes

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

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

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

05104                 {
05105                         return NAME;
05106                 }

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

References EMAN::TypeDict::put().

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

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

Definition at line 5113 of file processor.h.

05114                 {
05115                         return new AddMaskShellProcessor();
05116                 }

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

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGERR, LOGWARN, nx, ny, EMAN::EMData::update(), x, and y.

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


Member Data Documentation

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

Definition at line 170 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:37:28 2012 for EMAN2 by  doxygen 1.3.9.1