#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "mask.addshells" |
nshells | number of shells to add |
Definition at line 5020 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 5030 of file processor.h. 05031 { 05032 return "Add additional shells/rings to an existing 1/0 mask image"; 05033 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5025 of file processor.h. 05026 {
05027 return NAME;
05028 }
|
|
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 5040 of file processor.h. References EMAN::TypeDict::put(). 05041 { 05042 TypeDict d; 05043 d.put("nshells", EMObject::INT, "number of shells to add"); 05044 return d; 05045 }
|
|
Definition at line 5035 of file processor.h. 05036 { 05037 return new AddMaskShellProcessor(); 05038 }
|
|
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 5499 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. 05500 { 05501 if (!image) { 05502 LOGWARN("NULL Image"); 05503 return; 05504 } 05505 05506 int nx = image->get_xsize(); 05507 int ny = image->get_ysize(); 05508 int nz = image->get_zsize(); 05509 05510 if (ny == 1) { 05511 LOGERR("Tried to add mask shell to 1d image"); 05512 return; 05513 } 05514 05515 int num_shells = params["nshells"]; 05516 05517 float *d = image->get_data(); 05518 float k = 0.99999f; 05519 int nxy = nx * ny; 05520 05521 if (nz == 1) { 05522 for (int i = 0; i < num_shells; i++) { 05523 for (int y = 1; y < ny - 1; y++) { 05524 int cur_y = y * nx; 05525 05526 for (int x = 1; x < nx - 1; x++) { 05527 int j = x + cur_y; 05528 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05529 d[j] = k; 05530 } 05531 } 05532 } 05533 k -= 0.00001f; 05534 } 05535 } 05536 else { 05537 for (int i = 0; i < num_shells; i++) { 05538 for (int z = 1; z < nz - 1; z++) { 05539 size_t cur_z = (size_t)z * nx * ny; 05540 05541 for (int y = 1; y < ny - 1; y++) { 05542 size_t cur_y = y * nx + cur_z; 05543 05544 for (int x = 1; x < nx - 1; x++) { 05545 size_t j = x + cur_y; 05546 05547 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05548 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05549 d[j] = k; 05550 } 05551 } 05552 } 05553 } 05554 05555 k -= 0.00001f; 05556 } 05557 } 05558 05559 size_t size = (size_t)nx * ny * nz; 05560 for (size_t i = 0; i < size; ++i) { 05561 if (d[i]) { 05562 d[i] = 1; 05563 } 05564 else { 05565 d[i] = 0; 05566 } 05567 } 05568 05569 image->update(); 05570 }
|
|
Definition at line 175 of file processor.cpp. |