#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 5057 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 5067 of file processor.h.
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5062 of file processor.h. References NAME. 05063 { 05064 return NAME; 05065 }
|
|
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 5077 of file processor.h. References EMAN::EMObject::INT, and EMAN::TypeDict::put(). 05078 { 05079 TypeDict d; 05080 d.put("nshells", EMObject::INT, "number of shells to add"); 05081 return d; 05082 }
|
|
Definition at line 5072 of file processor.h. 05073 { 05074 return new AddMaskShellProcessor(); 05075 }
|
|
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.
Implements EMAN::Processor. Definition at line 5548 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. 05549 { 05550 if (!image) { 05551 LOGWARN("NULL Image"); 05552 return; 05553 } 05554 05555 int nx = image->get_xsize(); 05556 int ny = image->get_ysize(); 05557 int nz = image->get_zsize(); 05558 05559 if (ny == 1) { 05560 LOGERR("Tried to add mask shell to 1d image"); 05561 return; 05562 } 05563 05564 int num_shells = params["nshells"]; 05565 05566 float *d = image->get_data(); 05567 float k = 0.99999f; 05568 int nxy = nx * ny; 05569 05570 if (nz == 1) { 05571 for (int i = 0; i < num_shells; i++) { 05572 for (int y = 1; y < ny - 1; y++) { 05573 int cur_y = y * nx; 05574 05575 for (int x = 1; x < nx - 1; x++) { 05576 int j = x + cur_y; 05577 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05578 d[j] = k; 05579 } 05580 } 05581 } 05582 k -= 0.00001f; 05583 } 05584 } 05585 else { 05586 for (int i = 0; i < num_shells; i++) { 05587 for (int z = 1; z < nz - 1; z++) { 05588 size_t cur_z = z * nx * ny; 05589 05590 for (int y = 1; y < ny - 1; y++) { 05591 size_t cur_y = y * nx + cur_z; 05592 05593 for (int x = 1; x < nx - 1; x++) { 05594 size_t j = x + cur_y; 05595 05596 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05597 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05598 d[j] = k; 05599 } 05600 } 05601 } 05602 } 05603 05604 k -= 0.00001f; 05605 } 05606 } 05607 05608 size_t size = nx * ny * nz; 05609 for (size_t i = 0; i < size; i++) { 05610 if (d[i]) { 05611 d[i] = 1; 05612 } 05613 else { 05614 d[i] = 0; 05615 } 05616 } 05617 05618 image->update(); 05619 }
|
|
Definition at line 5084 of file processor.h. Referenced by get_name(). |