#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 4982 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 4992 of file processor.h. 04993 {
04994 return "Add additional shells/rings to an existing 1/0 mask image";
04995 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4987 of file processor.h. 04988 {
04989 return NAME;
04990 }
|
|
|
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 5002 of file processor.h. References EMAN::TypeDict::put(). 05003 {
05004 TypeDict d;
05005 d.put("nshells", EMObject::INT, "number of shells to add");
05006 return d;
05007 }
|
|
|
Definition at line 4997 of file processor.h. 04998 {
04999 return new AddMaskShellProcessor();
05000 }
|
|
|
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 5471 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. 05472 {
05473 if (!image) {
05474 LOGWARN("NULL Image");
05475 return;
05476 }
05477
05478 int nx = image->get_xsize();
05479 int ny = image->get_ysize();
05480 int nz = image->get_zsize();
05481
05482 if (ny == 1) {
05483 LOGERR("Tried to add mask shell to 1d image");
05484 return;
05485 }
05486
05487 int num_shells = params["nshells"];
05488
05489 float *d = image->get_data();
05490 float k = 0.99999f;
05491 int nxy = nx * ny;
05492
05493 if (nz == 1) {
05494 for (int i = 0; i < num_shells; i++) {
05495 for (int y = 1; y < ny - 1; y++) {
05496 int cur_y = y * nx;
05497
05498 for (int x = 1; x < nx - 1; x++) {
05499 int j = x + cur_y;
05500 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) {
05501 d[j] = k;
05502 }
05503 }
05504 }
05505 k -= 0.00001f;
05506 }
05507 }
05508 else {
05509 for (int i = 0; i < num_shells; i++) {
05510 for (int z = 1; z < nz - 1; z++) {
05511 size_t cur_z = (size_t)z * nx * ny;
05512
05513 for (int y = 1; y < ny - 1; y++) {
05514 size_t cur_y = y * nx + cur_z;
05515
05516 for (int x = 1; x < nx - 1; x++) {
05517 size_t j = x + cur_y;
05518
05519 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k ||
05520 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) {
05521 d[j] = k;
05522 }
05523 }
05524 }
05525 }
05526
05527 k -= 0.00001f;
05528 }
05529 }
05530
05531 size_t size = (size_t)nx * ny * nz;
05532 for (size_t i = 0; i < size; ++i) {
05533 if (d[i]) {
05534 d[i] = 1;
05535 }
05536 else {
05537 d[i] = 0;
05538 }
05539 }
05540
05541 image->update();
05542 }
|
|
|
Definition at line 169 of file processor.cpp. |
1.3.9.1