#include <processor.h>


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 () |
| nshells | number of shells to add |
Definition at line 4704 of file processor.h.
| 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 5066 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.
05067 { 05068 if (!image) { 05069 LOGWARN("NULL Image"); 05070 return; 05071 } 05072 05073 int nx = image->get_xsize(); 05074 int ny = image->get_ysize(); 05075 int nz = image->get_zsize(); 05076 05077 if (ny == 1) { 05078 LOGERR("Tried to add mask shell to 1d image"); 05079 return; 05080 } 05081 05082 int num_shells = params["nshells"]; 05083 05084 float *d = image->get_data(); 05085 float k = 0.99999f; 05086 int nxy = nx * ny; 05087 05088 if (nz == 1) { 05089 for (int i = 0; i < num_shells; i++) { 05090 for (int y = 1; y < ny - 1; y++) { 05091 int cur_y = y * nx; 05092 05093 for (int x = 1; x < nx - 1; x++) { 05094 int j = x + cur_y; 05095 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || d[j - nx] > k)) { 05096 d[j] = k; 05097 } 05098 } 05099 } 05100 k -= 0.00001f; 05101 } 05102 } 05103 else { 05104 for (int i = 0; i < num_shells; i++) { 05105 for (int z = 1; z < nz - 1; z++) { 05106 size_t cur_z = z * nx * ny; 05107 05108 for (int y = 1; y < ny - 1; y++) { 05109 size_t cur_y = y * nx + cur_z; 05110 05111 for (int x = 1; x < nx - 1; x++) { 05112 size_t j = x + cur_y; 05113 05114 if (!d[j] && (d[j - 1] > k || d[j + 1] > k || d[j + nx] > k || 05115 d[j - nx] > k || d[j - nxy] > k || d[j + nxy] > k)) { 05116 d[j] = k; 05117 } 05118 } 05119 } 05120 } 05121 05122 k -= 0.00001f; 05123 } 05124 } 05125 05126 size_t size = nx * ny * nz; 05127 for (size_t i = 0; i < size; i++) { 05128 if (d[i]) { 05129 d[i] = 1; 05130 } 05131 else { 05132 d[i] = 0; 05133 } 05134 } 05135 05136 image->update(); 05137 }
| 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 4709 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 4714 of file processor.h.
| static Processor* EMAN::AddMaskShellProcessor::NEW | ( | ) | [inline, static] |
Definition at line 4719 of file processor.h.
04720 { 04721 return new AddMaskShellProcessor(); 04722 }
| 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 4724 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
04725 { 04726 TypeDict d; 04727 d.put("nshells", EMObject::INT, "number of shells to add"); 04728 return d; 04729 }
1.5.6