#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 5016 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 5026 of file processor.h. 05027 { 05028 return "Add additional shells/rings to an existing 1/0 mask image"; 05029 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5021 of file processor.h. 05022 {
05023 return NAME;
05024 }
|
|
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 5036 of file processor.h. References EMAN::TypeDict::put(). 05037 { 05038 TypeDict d; 05039 d.put("nshells", EMObject::INT, "number of shells to add"); 05040 return d; 05041 }
|
|
Definition at line 5031 of file processor.h. 05032 { 05033 return new AddMaskShellProcessor(); 05034 }
|
|
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 5410 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. 05411 { 05412 if (!image) { 05413 LOGWARN("NULL Image"); 05414 return; 05415 } 05416 05417 int nx = image->get_xsize(); 05418 int ny = image->get_ysize(); 05419 int nz = image->get_zsize(); 05420 05421 if (ny == 1) { 05422 LOGERR("Tried to add mask shell to 1d image"); 05423 return; 05424 } 05425 05426 int num_shells = params["nshells"]; 05427 05428 float *d = image->get_data(); 05429 float k = 0.99999f; 05430 int nxy = nx * ny; 05431 05432 if (nz == 1) { 05433 for (int i = 0; i < num_shells; i++) { 05434 for (int y = 1; y < ny - 1; y++) { 05435 int cur_y = y * nx; 05436 05437 for (int x = 1; x < nx - 1; x++) { 05438 int j = x + cur_y; 05439 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05440 d[j] = k; 05441 } 05442 } 05443 } 05444 k -= 0.00001f; 05445 } 05446 } 05447 else { 05448 for (int i = 0; i < num_shells; i++) { 05449 for (int z = 1; z < nz - 1; z++) { 05450 size_t cur_z = z * nx * ny; 05451 05452 for (int y = 1; y < ny - 1; y++) { 05453 size_t cur_y = y * nx + cur_z; 05454 05455 for (int x = 1; x < nx - 1; x++) { 05456 size_t j = x + cur_y; 05457 05458 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05459 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05460 d[j] = k; 05461 } 05462 } 05463 } 05464 } 05465 05466 k -= 0.00001f; 05467 } 05468 } 05469 05470 size_t size = nx * ny * nz; 05471 for (size_t i = 0; i < size; i++) { 05472 if (d[i]) { 05473 d[i] = 1; 05474 } 05475 else { 05476 d[i] = 0; 05477 } 05478 } 05479 05480 image->update(); 05481 }
|
|
Definition at line 169 of file processor.cpp. |