#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 4926 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 4936 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 4931 of file processor.h.
References NAME.
04932 { 04933 return NAME; 04934 }
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 4946 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
04947 { 04948 TypeDict d; 04949 d.put("nshells", EMObject::INT, "number of shells to add"); 04950 return d; 04951 }
static Processor* EMAN::AddMaskShellProcessor::NEW | ( | ) | [inline, static] |
Definition at line 4941 of file processor.h.
04942 { 04943 return new AddMaskShellProcessor(); 04944 }
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 5473 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.
05474 { 05475 if (!image) { 05476 LOGWARN("NULL Image"); 05477 return; 05478 } 05479 05480 int nx = image->get_xsize(); 05481 int ny = image->get_ysize(); 05482 int nz = image->get_zsize(); 05483 05484 if (ny == 1) { 05485 LOGERR("Tried to add mask shell to 1d image"); 05486 return; 05487 } 05488 05489 int num_shells = params["nshells"]; 05490 05491 float *d = image->get_data(); 05492 float k = 0.99999f; 05493 int nxy = nx * ny; 05494 05495 if (nz == 1) { 05496 for (int i = 0; i < num_shells; i++) { 05497 for (int y = 1; y < ny - 1; y++) { 05498 int cur_y = y * nx; 05499 05500 for (int x = 1; x < nx - 1; x++) { 05501 int j = x + cur_y; 05502 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05503 d[j] = k; 05504 } 05505 } 05506 } 05507 k -= 0.00001f; 05508 } 05509 } 05510 else { 05511 for (int i = 0; i < num_shells; i++) { 05512 for (int z = 1; z < nz - 1; z++) { 05513 size_t cur_z = (size_t)z * nx * ny; 05514 05515 for (int y = 1; y < ny - 1; y++) { 05516 size_t cur_y = y * nx + cur_z; 05517 05518 for (int x = 1; x < nx - 1; x++) { 05519 size_t j = x + cur_y; 05520 05521 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05522 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05523 d[j] = k; 05524 } 05525 } 05526 } 05527 } 05528 05529 k -= 0.00001f; 05530 } 05531 } 05532 05533 size_t size = (size_t)nx * ny * nz; 05534 for (size_t i = 0; i < size; ++i) { 05535 if (d[i]) { 05536 d[i] = 1; 05537 } 05538 else { 05539 d[i] = 0; 05540 } 05541 } 05542 05543 image->update(); 05544 }
const string AddMaskShellProcessor::NAME = "mask.addshells" [static] |