#include <processor.h>
Inheritance diagram for EMAN::AddMaskShellProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "mask.addshells" |
nshells | number of shells to add |
Definition at line 5051 of file processor.h.
virtual string EMAN::AddMaskShellProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 5061 of file processor.h.
virtual string EMAN::AddMaskShellProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5056 of file processor.h.
References NAME.
05057 { 05058 return NAME; 05059 }
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.
Reimplemented from EMAN::Processor.
Definition at line 5071 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
05072 { 05073 TypeDict d; 05074 d.put("nshells", EMObject::INT, "number of shells to add"); 05075 return d; 05076 }
static Processor* EMAN::AddMaskShellProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5066 of file processor.h.
05067 { 05068 return new AddMaskShellProcessor(); 05069 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 5585 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.
05586 { 05587 if (!image) { 05588 LOGWARN("NULL Image"); 05589 return; 05590 } 05591 05592 int nx = image->get_xsize(); 05593 int ny = image->get_ysize(); 05594 int nz = image->get_zsize(); 05595 05596 if (ny == 1) { 05597 LOGERR("Tried to add mask shell to 1d image"); 05598 return; 05599 } 05600 05601 int num_shells = params["nshells"]; 05602 05603 float *d = image->get_data(); 05604 float k = 0.99999f; 05605 int nxy = nx * ny; 05606 05607 if (nz == 1) { 05608 for (int i = 0; i < num_shells; i++) { 05609 for (int y = 1; y < ny - 1; y++) { 05610 int cur_y = y * nx; 05611 05612 for (int x = 1; x < nx - 1; x++) { 05613 int j = x + cur_y; 05614 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05615 d[j] = k; 05616 } 05617 } 05618 } 05619 k -= 0.00001f; 05620 } 05621 } 05622 else { 05623 for (int i = 0; i < num_shells; i++) { 05624 for (int z = 1; z < nz - 1; z++) { 05625 size_t cur_z = (size_t)z * nx * ny; 05626 05627 for (int y = 1; y < ny - 1; y++) { 05628 size_t cur_y = y * nx + cur_z; 05629 05630 for (int x = 1; x < nx - 1; x++) { 05631 size_t j = x + cur_y; 05632 05633 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05634 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05635 d[j] = k; 05636 } 05637 } 05638 } 05639 } 05640 05641 k -= 0.00001f; 05642 } 05643 } 05644 05645 size_t size = (size_t)nx * ny * nz; 05646 for (size_t i = 0; i < size; ++i) { 05647 if (d[i]) { 05648 d[i] = 1; 05649 } 05650 else { 05651 d[i] = 0; 05652 } 05653 } 05654 05655 image->update(); 05656 }
const string AddMaskShellProcessor::NAME = "mask.addshells" [static] |