#include <processor.h>
Inheritance diagram for EMAN::ToMassCenterProcessor:
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 = "xform.centerofmass" |
int_shift_only | set to 1 only shift by integer, no interpolation |
Definition at line 5125 of file processor.h.
virtual string EMAN::ToMassCenterProcessor::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 5140 of file processor.h.
05141 { 05142 return "ToMassCenterProcessor centers image at center of mass. Note: includes only values > mean+0.75*sigma"; 05143 }
virtual string EMAN::ToMassCenterProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 5130 of file processor.h.
References NAME.
05131 { 05132 return NAME; 05133 }
virtual TypeDict EMAN::ToMassCenterProcessor::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 5145 of file processor.h.
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
05146 { 05147 TypeDict d; 05148 d.put("int_shift_only", EMObject::INT, "set to 1 only shift by integer, no interpolation"); 05149 // d.put("positive", EMObject::INT, "uses only densities >0 for the calculatton"); 05150 return d; 05151 }
static Processor* EMAN::ToMassCenterProcessor::NEW | ( | ) | [inline, static] |
Definition at line 5135 of file processor.h.
05136 { 05137 return new ToMassCenterProcessor(); 05138 }
void ToMassCenterProcessor::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 5621 of file processor.cpp.
References EMAN::EMData::calc_center_of_mass(), EMAN::EMObject::f, EMAN::EMData::get_attr(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, EMAN::Processor::params, EMAN::EMData::set_attr(), EMAN::Dict::set_default(), t, and EMAN::EMData::translate().
05622 { 05623 if (!image) { 05624 LOGWARN("NULL Image"); 05625 return; 05626 } 05627 05628 int int_shift_only = params.set_default("int_shift_only",1); 05629 // int positive = params.set_default("positive",0); 05630 05631 if ((float)image->get_attr("sigma")==0.0f) return; // Can't center a constant valued image 05632 05633 FloatPoint com = image->calc_center_of_mass(); 05634 05635 int nx = image->get_xsize(); 05636 int ny = image->get_ysize(); 05637 int nz = image->get_zsize(); 05638 05639 if (int_shift_only) { 05640 int dx = -(int)(floor(com[0] + 0.5f) - nx / 2); 05641 int dy = -(int)(floor(com[1] + 0.5f) - ny / 2); 05642 int dz = 0; 05643 if (nz > 1) { 05644 dz = -(int)(floor(com[2] + 0.5f) - nz / 2); 05645 } 05646 image->translate(dx, dy, dz); 05647 05648 Transform t; 05649 t.set_trans((float)dx,(float)dy,(float)dz); 05650 05651 if (nz > 1) { 05652 image->set_attr("xform.align3d",&t); 05653 } else { 05654 image->set_attr("xform.align2d",&t); 05655 } 05656 } 05657 else { 05658 float dx = -(com[0] - nx / 2); 05659 float dy = -(com[1] - ny / 2); 05660 float dz = 0; 05661 if (nz > 1) { 05662 dz = -(com[2] - nz / 2); 05663 } 05664 image->translate(dx, dy, dz); 05665 05666 Transform t; 05667 t.set_trans(dx,dy,dz); 05668 05669 if (nz > 1) { 05670 image->set_attr("xform.align3d",&t); 05671 } else { 05672 image->set_attr("xform.align2d",&t); 05673 } 05674 } 05675 }
const string ToMassCenterProcessor::NAME = "xform.centerofmass" [static] |