#include <processor.h>
Inheritance diagram for EMAN::SmartMaskProcessor:


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.smart" |
| mask | mask value |
Definition at line 5665 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 5680 of file processor.h. 05681 {
05682 return "Smart mask processor.";
05683 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5670 of file processor.h. 05671 {
05672 return NAME;
05673 }
|
|
|
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 5685 of file processor.h. References EMAN::TypeDict::put(). 05686 {
05687 TypeDict d;
05688 d.put("mask", EMObject::FLOAT, "mask value");
05689 return d;
05690 }
|
|
|
Definition at line 5675 of file processor.h. 05676 {
05677 return new SmartMaskProcessor();
05678 }
|
|
|
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 6136 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, sqrt(), and EMAN::EMData::update(). 06137 {
06138 if (!image) {
06139 LOGWARN("NULL Image");
06140 return;
06141 }
06142
06143 float mask = params["mask"];
06144
06145 int nx = image->get_xsize();
06146 int ny = image->get_ysize();
06147 int nz = image->get_zsize();
06148
06149 float *dat = image->get_data();
06150 double sma = 0;
06151 size_t smn = 0;
06152 float r = 0.0f;
06153 for (int k = 0; k < nz; ++k) {
06154 for (int j = 0; j < ny; ++j) {
06155 for (int i = 0; i < nx; ++i, ++dat) {
06156 r =
06157 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
06158 Util::square(k - nz / 2));
06159 if (r > mask - 1.5f && r < mask - 0.5f) {
06160 sma += *dat;
06161 smn++;
06162 }
06163 }
06164 }
06165 }
06166
06167 float smask = (float) (sma / smn);
06168 image->update();
06169
06170 dat = image->get_data();
06171 for (int k = 0; k < nz; ++k) {
06172 for (int j = 0; j < ny; ++j) {
06173 for (int i = 0; i < nx; ++i, ++dat) {
06174 r =
06175 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) +
06176 Util::square(k - nz / 2));
06177 if (r > mask - .5) {
06178 *dat = 0;
06179 }
06180 else {
06181 *dat -= smask;
06182 }
06183 }
06184 }
06185 }
06186
06187 image->update();
06188 }
|
|
|
Definition at line 188 of file processor.cpp. |
1.3.9.1