#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 | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "mask.smart" |
mask | mask value |
Definition at line 5697 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 5712 of file processor.h.
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5702 of file processor.h. References NAME. 05703 { 05704 return NAME; 05705 }
|
|
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 5717 of file processor.h. References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put(). 05718 { 05719 TypeDict d; 05720 d.put("mask", EMObject::FLOAT, "mask value"); 05721 return d; 05722 }
|
|
Definition at line 5707 of file processor.h. 05708 { 05709 return new SmartMaskProcessor(); 05710 }
|
|
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 6101 of file processor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, sqrt(), EMAN::Util::square(), and EMAN::EMData::update(). 06102 { 06103 if (!image) { 06104 LOGWARN("NULL Image"); 06105 return; 06106 } 06107 06108 float mask = params["mask"]; 06109 06110 int nx = image->get_xsize(); 06111 int ny = image->get_ysize(); 06112 int nz = image->get_zsize(); 06113 06114 float *dat = image->get_data(); 06115 double sma = 0; 06116 int smn = 0; 06117 float r = 0.0f; 06118 for (int k = 0; k < nz; ++k) { 06119 for (int j = 0; j < ny; ++j) { 06120 for (int i = 0; i < nx; ++i, ++dat) { 06121 r = 06122 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) + 06123 Util::square(k - nz / 2)); 06124 if (r > mask - 1.5f && r < mask - 0.5f) { 06125 sma += *dat; 06126 smn++; 06127 } 06128 } 06129 } 06130 } 06131 06132 float smask = (float) sma / smn; 06133 image->update(); 06134 06135 dat = image->get_data(); 06136 for (int k = 0; k < nz; ++k) { 06137 for (int j = 0; j < ny; ++j) { 06138 for (int i = 0; i < nx; ++i, ++dat) { 06139 r = 06140 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) + 06141 Util::square(k - nz / 2)); 06142 if (r > mask - .5) { 06143 *dat = 0; 06144 } 06145 else { 06146 *dat -= smask; 06147 } 06148 } 06149 } 06150 } 06151 06152 image->update(); 06153 }
|
|
Definition at line 5724 of file processor.h. Referenced by get_name(). |