#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 5100 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 5110 of file processor.h. 05111 { 05112 return "Add additional shells/rings to an existing 1/0 mask image"; 05113 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5105 of file processor.h. 05106 {
05107 return NAME;
05108 }
|
|
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 5120 of file processor.h. References EMAN::TypeDict::put(). 05121 { 05122 TypeDict d; 05123 d.put("nshells", EMObject::INT, "number of shells to add"); 05124 return d; 05125 }
|
|
Definition at line 5115 of file processor.h. 05116 { 05117 return new AddMaskShellProcessor(); 05118 }
|
|
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 5663 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. 05664 { 05665 if (!image) { 05666 LOGWARN("NULL Image"); 05667 return; 05668 } 05669 05670 int nx = image->get_xsize(); 05671 int ny = image->get_ysize(); 05672 int nz = image->get_zsize(); 05673 05674 if (ny == 1) { 05675 LOGERR("Tried to add mask shell to 1d image"); 05676 return; 05677 } 05678 05679 int num_shells = params["nshells"]; 05680 05681 float *d = image->get_data(); 05682 float k = 0.99999f; 05683 int nxy = nx * ny; 05684 05685 if (nz == 1) { 05686 for (int i = 0; i < num_shells; i++) { 05687 for (int y = 1; y < ny - 1; y++) { 05688 int cur_y = y * nx; 05689 05690 for (int x = 1; x < nx - 1; x++) { 05691 int j = x + cur_y; 05692 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05693 d[j] = k; 05694 } 05695 } 05696 } 05697 k -= 0.00001f; 05698 } 05699 } 05700 else { 05701 for (int i = 0; i < num_shells; i++) { 05702 for (int z = 1; z < nz - 1; z++) { 05703 size_t cur_z = (size_t)z * nx * ny; 05704 05705 for (int y = 1; y < ny - 1; y++) { 05706 size_t cur_y = y * nx + cur_z; 05707 05708 for (int x = 1; x < nx - 1; x++) { 05709 size_t j = x + cur_y; 05710 05711 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05712 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05713 d[j] = k; 05714 } 05715 } 05716 } 05717 } 05718 05719 k -= 0.00001f; 05720 } 05721 } 05722 05723 size_t size = (size_t)nx * ny * nz; 05724 for (size_t i = 0; i < size; ++i) { 05725 if (d[i]) { 05726 d[i] = 1; 05727 } 05728 else { 05729 d[i] = 0; 05730 } 05731 } 05732 05733 image->update(); 05734 }
|
|
Definition at line 170 of file processor.cpp. |