#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 5820 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 5835 of file processor.h. 05836 { 05837 return "Smart mask processor."; 05838 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5825 of file processor.h. 05826 {
05827 return NAME;
05828 }
|
|
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 5840 of file processor.h. References EMAN::TypeDict::put(). 05841 { 05842 TypeDict d; 05843 d.put("mask", EMObject::FLOAT, "mask value"); 05844 return d; 05845 }
|
|
Definition at line 5830 of file processor.h. 05831 { 05832 return new SmartMaskProcessor(); 05833 }
|
|
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 6397 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(). 06398 { 06399 if (!image) { 06400 LOGWARN("NULL Image"); 06401 return; 06402 } 06403 06404 float mask = params["mask"]; 06405 06406 int nx = image->get_xsize(); 06407 int ny = image->get_ysize(); 06408 int nz = image->get_zsize(); 06409 06410 float *dat = image->get_data(); 06411 double sma = 0; 06412 size_t smn = 0; 06413 float r = 0.0f; 06414 for (int k = 0; k < nz; ++k) { 06415 for (int j = 0; j < ny; ++j) { 06416 for (int i = 0; i < nx; ++i, ++dat) { 06417 r = 06418 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) + 06419 Util::square(k - nz / 2)); 06420 if (r > mask - 1.5f && r < mask - 0.5f) { 06421 sma += *dat; 06422 smn++; 06423 } 06424 } 06425 } 06426 } 06427 06428 float smask = (float) (sma / smn); 06429 image->update(); 06430 06431 dat = image->get_data(); 06432 for (int k = 0; k < nz; ++k) { 06433 for (int j = 0; j < ny; ++j) { 06434 for (int i = 0; i < nx; ++i, ++dat) { 06435 r = 06436 sqrt((float) Util::square(i - nx / 2) + Util::square(j - ny / 2) + 06437 Util::square(k - nz / 2)); 06438 if (r > mask - .5) { 06439 *dat = 0; 06440 } 06441 else { 06442 *dat -= smask; 06443 } 06444 } 06445 } 06446 } 06447 06448 image->update(); 06449 }
|
|
Definition at line 189 of file processor.cpp. |