#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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "xform.centerofmass" |
int_shift_only | set to 1 only shift by integer, no interpolation |
Definition at line 4909 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 4924 of file processor.h. 04925 { 04926 return "ToMassCenterProcessor centers image at center of mass, with a threshold. Only values higher than the threshold are considered."; 04927 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 4914 of file processor.h. 04915 {
04916 return NAME;
04917 }
|
|
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 4929 of file processor.h. References EMAN::TypeDict::put(). 04930 { 04931 TypeDict d; 04932 d.put("int_shift_only", EMObject::INT, "set to 1 only shift by integer, no interpolation"); 04933 d.put("threshold", EMObject::FLOAT, "Only values larger than the threshold are included in the center of mass computation. Default is 0."); 04934 // d.put("positive", EMObject::INT, "uses only densities >0 for the calculatton"); 04935 return d; 04936 }
|
|
Definition at line 4919 of file processor.h. 04920 { 04921 return new ToMassCenterProcessor(); 04922 }
|
|
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 5482 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, nx, ny, EMAN::EMData::set_attr(), EMAN::Dict::set_default(), EMAN::Transform::set_trans(), t, and EMAN::EMData::translate(). 05483 { 05484 if (!image) { 05485 LOGWARN("NULL Image"); 05486 return; 05487 } 05488 05489 int int_shift_only = params.set_default("int_shift_only",1); 05490 float threshold = params.set_default("threshold",0.0); 05491 // int positive = params.set_default("positive",0); 05492 05493 if ((float)image->get_attr("sigma")==0.0f) return; // Can't center a constant valued image 05494 05495 FloatPoint com = image->calc_center_of_mass(threshold); 05496 05497 int nx = image->get_xsize(); 05498 int ny = image->get_ysize(); 05499 int nz = image->get_zsize(); 05500 05501 if (int_shift_only) { 05502 int dx = -(int)(floor(com[0] + 0.5f) - nx / 2); 05503 int dy = -(int)(floor(com[1] + 0.5f) - ny / 2); 05504 int dz = 0; 05505 if (nz > 1) { 05506 dz = -(int)(floor(com[2] + 0.5f) - nz / 2); 05507 } 05508 image->translate(dx, dy, dz); 05509 05510 Transform t; 05511 t.set_trans((float)dx,(float)dy,(float)dz); 05512 05513 if (nz > 1) { 05514 image->set_attr("xform.align3d",&t); 05515 } else { 05516 image->set_attr("xform.align2d",&t); 05517 } 05518 } 05519 else { 05520 float dx = -(com[0] - nx / 2); 05521 float dy = -(com[1] - ny / 2); 05522 float dz = 0; 05523 if (nz > 1) { 05524 dz = -(com[2] - nz / 2); 05525 } 05526 image->translate(dx, dy, dz); 05527 05528 Transform t; 05529 t.set_trans(dx,dy,dz); 05530 05531 if (nz > 1) { 05532 image->set_attr("xform.align3d",&t); 05533 } else { 05534 image->set_attr("xform.align2d",&t); 05535 } 05536 } 05537 }
|
|
Definition at line 166 of file processor.cpp. |