#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 5168 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 5183 of file processor.h. 05184 { 05185 return "ToMassCenterProcessor centers image at center of mass, with a threshold. Only values higher than the threshold are considered."; 05186 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5173 of file processor.h. 05174 {
05175 return NAME;
05176 }
|
|
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 5188 of file processor.h. References EMAN::TypeDict::put(). 05189 { 05190 TypeDict d; 05191 d.put("int_shift_only", EMObject::INT, "set to 1 only shift by integer, no interpolation"); 05192 d.put("threshold", EMObject::FLOAT, "Only values larger than the threshold are included in the center of mass computation. Default is 0."); 05193 // d.put("positive", EMObject::INT, "uses only densities >0 for the calculatton"); 05194 return d; 05195 }
|
|
Definition at line 5178 of file processor.h. 05179 { 05180 return new ToMassCenterProcessor(); 05181 }
|
|
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 5736 of file processor.cpp. References abs, 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(). 05737 { 05738 if (!image) { 05739 LOGWARN("NULL Image"); 05740 return; 05741 } 05742 05743 int int_shift_only = params.set_default("int_shift_only",1); 05744 float threshold = params.set_default("threshold",0.0f); 05745 // int positive = params.set_default("positive",0); 05746 05747 if ((float)image->get_attr("sigma")==0.0f) return; // Can't center a constant valued image 05748 if (threshold>(float)image->get_attr("maximum")) { 05749 printf("Warning, centering threshold %1.2f, but image max %1.2f. Adjusting.",threshold,(float)image->get_attr("maximum")); 05750 threshold=(float)image->get_attr("mean")+(float)image->get_attr("sigma"); 05751 } 05752 05753 FloatPoint com = image->calc_center_of_mass(threshold); 05754 05755 int nx = image->get_xsize(); 05756 int ny = image->get_ysize(); 05757 int nz = image->get_zsize(); 05758 05759 if (int_shift_only) { 05760 int dx = -(int)(floor(com[0] + 0.5f) - nx / 2); 05761 int dy = -(int)(floor(com[1] + 0.5f) - ny / 2); 05762 int dz = 0; 05763 if (nz > 1) { 05764 dz = -(int)(floor(com[2] + 0.5f) - nz / 2); 05765 } 05766 if (abs(dx)>=nx-1 || abs(dy)>=ny-1 || abs(dz)>=nz) { 05767 printf("ERROR, center of mass outside image\n"); 05768 } 05769 else { 05770 image->translate(dx, dy, dz); 05771 05772 Transform t; 05773 t.set_trans((float)dx,(float)dy,(float)dz); 05774 05775 if (nz > 1) { 05776 image->set_attr("xform.align3d",&t); 05777 } else { 05778 image->set_attr("xform.align2d",&t); 05779 } 05780 } 05781 } 05782 else { 05783 float dx = -(com[0] - nx / 2); 05784 float dy = -(com[1] - ny / 2); 05785 float dz = 0; 05786 if (nz > 1) { 05787 dz = -(com[2] - nz / 2); 05788 } 05789 if (fabs(dx)>=nx-1 || fabs(dy)>=ny-2 || fabs(dz)>=nz) { 05790 printf("ERROR, center of mass outside image\n"); 05791 } 05792 else { 05793 image->translate(dx, dy, dz); 05794 05795 Transform t; 05796 t.set_trans(dx,dy,dz); 05797 05798 if (nz > 1) { 05799 image->set_attr("xform.align3d",&t); 05800 } else { 05801 image->set_attr("xform.align2d",&t); 05802 } 05803 } 05804 } 05805 }
|
|
Definition at line 172 of file processor.cpp. |