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

04852                 {
04853                         return "Add additional shells/rings to an existing 1/0 mask image";
04854                 }

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

04847                 {
04848                         return NAME;
04849                 }

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

References EMAN::TypeDict::put().

04862                 {
04863                         TypeDict d;
04864                         d.put("nshells", EMObject::INT, "number of shells to add");
04865                         return d;
04866                 }

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

Definition at line 4856 of file processor.h.

04857                 {
04858                         return new AddMaskShellProcessor();
04859                 }

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

05410 {
05411         if (!image) {
05412                 LOGWARN("NULL Image");
05413                 return;
05414         }
05415 
05416         int nx = image->get_xsize();
05417         int ny = image->get_ysize();
05418         int nz = image->get_zsize();
05419 
05420         if (ny == 1) {
05421                 LOGERR("Tried to add mask shell to 1d image");
05422                 return;
05423         }
05424 
05425         int num_shells = params["nshells"];
05426 
05427         float *d = image->get_data();
05428         float k = 0.99999f;
05429         int nxy = nx * ny;
05430 
05431         if (nz == 1) {
05432                 for (int i = 0; i < num_shells; i++) {
05433                         for (int y = 1; y < ny - 1; y++) {
05434                                 int cur_y = y * nx;
05435 
05436                                 for (int x = 1; x < nx - 1; x++) {
05437                                         int j = x + cur_y;
05438                                         if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
05439                                                 d[j] = k;
05440                                         }
05441                                 }
05442                         }
05443                         k -= 0.00001f;
05444                 }
05445         }
05446         else {
05447                 for (int i = 0; i < num_shells; i++) {
05448                         for (int z = 1; z < nz - 1; z++) {
05449                                 size_t cur_z = z * nx * ny;
05450 
05451                                 for (int y = 1; y < ny - 1; y++) {
05452                                         size_t cur_y = y * nx + cur_z;
05453 
05454                                         for (int x = 1; x < nx - 1; x++) {
05455                                                 size_t j = x + cur_y;
05456 
05457                                                 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
05458                                                                           d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
05459                                                         d[j] = k;
05460                                                 }
05461                                         }
05462                                 }
05463                         }
05464 
05465                         k -= 0.00001f;
05466                 }
05467         }
05468 
05469         size_t size = nx * ny * nz;
05470         for (size_t i = 0; i < size; i++) {
05471                 if (d[i]) {
05472                         d[i] = 1;
05473                 }
05474                 else {
05475                         d[i] = 0;
05476                 }
05477         }
05478 
05479         image->update();
05480 }


Member Data Documentation

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

Definition at line 164 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 13:48:12 2010 for EMAN2 by  doxygen 1.3.9.1