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

04993                 {
04994                         return "Add additional shells/rings to an existing 1/0 mask image";
04995                 }

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

04988                 {
04989                         return NAME;
04990                 }

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

References EMAN::TypeDict::put().

05003                 {
05004                         TypeDict d;
05005                         d.put("nshells", EMObject::INT, "number of shells to add");
05006                         return d;
05007                 }

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

Definition at line 4997 of file processor.h.

04998                 {
04999                         return new AddMaskShellProcessor();
05000                 }

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

05472 {
05473         if (!image) {
05474                 LOGWARN("NULL Image");
05475                 return;
05476         }
05477 
05478         int nx = image->get_xsize();
05479         int ny = image->get_ysize();
05480         int nz = image->get_zsize();
05481 
05482         if (ny == 1) {
05483                 LOGERR("Tried to add mask shell to 1d image");
05484                 return;
05485         }
05486 
05487         int num_shells = params["nshells"];
05488 
05489         float *d = image->get_data();
05490         float k = 0.99999f;
05491         int nxy = nx * ny;
05492 
05493         if (nz == 1) {
05494                 for (int i = 0; i < num_shells; i++) {
05495                         for (int y = 1; y < ny - 1; y++) {
05496                                 int cur_y = y * nx;
05497 
05498                                 for (int x = 1; x < nx - 1; x++) {
05499                                         int j = x + cur_y;
05500                                         if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
05501                                                 d[j] = k;
05502                                         }
05503                                 }
05504                         }
05505                         k -= 0.00001f;
05506                 }
05507         }
05508         else {
05509                 for (int i = 0; i < num_shells; i++) {
05510                         for (int z = 1; z < nz - 1; z++) {
05511                                 size_t cur_z = (size_t)z * nx * ny;
05512 
05513                                 for (int y = 1; y < ny - 1; y++) {
05514                                         size_t cur_y = y * nx + cur_z;
05515 
05516                                         for (int x = 1; x < nx - 1; x++) {
05517                                                 size_t j = x + cur_y;
05518 
05519                                                 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
05520                                                                           d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
05521                                                         d[j] = k;
05522                                                 }
05523                                         }
05524                                 }
05525                         }
05526 
05527                         k -= 0.00001f;
05528                 }
05529         }
05530 
05531         size_t size = (size_t)nx * ny * nz;
05532         for (size_t i = 0; i < size; ++i) {
05533                 if (d[i]) {
05534                         d[i] = 1;
05535                 }
05536                 else {
05537                         d[i] = 0;
05538                 }
05539         }
05540 
05541         image->update();
05542 }


Member Data Documentation

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

Definition at line 169 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Mon May 2 13:30:38 2011 for EMAN2 by  doxygen 1.3.9.1