#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 5017 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 5027 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 5022 of file processor.h.
References NAME.
05023 { 05024 return NAME; 05025 }
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 5037 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
05038 { 05039 TypeDict d; 05040 d.put("nshells", EMObject::INT, "number of shells to add"); 05041 return d; 05042 }
static Processor* EMAN::AddMaskShellProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5032 of file processor.h.
05033 { 05034 return new AddMaskShellProcessor(); 05035 }
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 5441 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.
05442 { 05443 if (!image) { 05444 LOGWARN("NULL Image"); 05445 return; 05446 } 05447 05448 int nx = image->get_xsize(); 05449 int ny = image->get_ysize(); 05450 int nz = image->get_zsize(); 05451 05452 if (ny == 1) { 05453 LOGERR("Tried to add mask shell to 1d image"); 05454 return; 05455 } 05456 05457 int num_shells = params["nshells"]; 05458 05459 float *d = image->get_data(); 05460 float k = 0.99999f; 05461 int nxy = nx * ny; 05462 05463 if (nz == 1) { 05464 for (int i = 0; i < num_shells; i++) { 05465 for (int y = 1; y < ny - 1; y++) { 05466 int cur_y = y * nx; 05467 05468 for (int x = 1; x < nx - 1; x++) { 05469 int j = x + cur_y; 05470 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05471 d[j] = k; 05472 } 05473 } 05474 } 05475 k -= 0.00001f; 05476 } 05477 } 05478 else { 05479 for (int i = 0; i < num_shells; i++) { 05480 for (int z = 1; z < nz - 1; z++) { 05481 size_t cur_z = z * nx * ny; 05482 05483 for (int y = 1; y < ny - 1; y++) { 05484 size_t cur_y = y * nx + cur_z; 05485 05486 for (int x = 1; x < nx - 1; x++) { 05487 size_t j = x + cur_y; 05488 05489 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05490 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05491 d[j] = k; 05492 } 05493 } 05494 } 05495 } 05496 05497 k -= 0.00001f; 05498 } 05499 } 05500 05501 size_t size = nx * ny * nz; 05502 for (size_t i = 0; i < size; i++) { 05503 if (d[i]) { 05504 d[i] = 1; 05505 } 05506 else { 05507 d[i] = 0; 05508 } 05509 } 05510 05511 image->update(); 05512 }
const string AddMaskShellProcessor::NAME = "mask.addshells" [static] |