#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 5609 of file processor.h.
virtual string EMAN::SmartMaskProcessor::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 5624 of file processor.h.
virtual string EMAN::SmartMaskProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5614 of file processor.h.
References NAME.
05615 { 05616 return NAME; 05617 }
virtual TypeDict EMAN::SmartMaskProcessor::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 5629 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
05630 { 05631 TypeDict d; 05632 d.put("mask", EMObject::FLOAT, "mask value"); 05633 return d; 05634 }
static Processor* EMAN::SmartMaskProcessor::NEW | ( | ) | [inline, static] |
void SmartMaskProcessor::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 6134 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().
06135 { 06136 if (!image) { 06137 LOGWARN("NULL Image"); 06138 return; 06139 } 06140 06141 float mask = params["mask"]; 06142 06143 int nx = image->get_xsize(); 06144 int ny = image->get_ysize(); 06145 int nz = image->get_zsize(); 06146 06147 float *dat = image->get_data(); 06148 double sma = 0; 06149 size_t smn = 0; 06150 float r = 0.0f; 06151 for (int k = 0; k < nz; ++k) { 06152 for (int j = 0; j < ny; ++j) { 06153 for (int i = 0; i < nx; ++i, ++dat) { 06154 r = 06155 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) + 06156 Util::square(k - nz / 2)); 06157 if (r > mask - 1.5f && r < mask - 0.5f) { 06158 sma += *dat; 06159 smn++; 06160 } 06161 } 06162 } 06163 } 06164 06165 float smask = (float) (sma / smn); 06166 image->update(); 06167 06168 dat = image->get_data(); 06169 for (int k = 0; k < nz; ++k) { 06170 for (int j = 0; j < ny; ++j) { 06171 for (int i = 0; i < nx; ++i, ++dat) { 06172 r = 06173 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) + 06174 Util::square(k - nz / 2)); 06175 if (r > mask - .5) { 06176 *dat = 0; 06177 } 06178 else { 06179 *dat -= smask; 06180 } 06181 } 06182 } 06183 } 06184 06185 image->update(); 06186 }
const string SmartMaskProcessor::NAME = "mask.smart" [static] |