#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 5050 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 5065 of file processor.h. 05066 {
05067 return "ToMassCenterProcessor centers image at center of mass, with a threshold. Only values higher than the threshold are considered.";
05068 }
|
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 5055 of file processor.h. 05056 {
05057 return NAME;
05058 }
|
|
|
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 5070 of file processor.h. References EMAN::TypeDict::put(). 05071 {
05072 TypeDict d;
05073 d.put("int_shift_only", EMObject::INT, "set to 1 only shift by integer, no interpolation");
05074 d.put("threshold", EMObject::FLOAT, "Only values larger than the threshold are included in the center of mass computation. Default is 0.");
05075 // d.put("positive", EMObject::INT, "uses only densities >0 for the calculatton");
05076 return d;
05077 }
|
|
|
Definition at line 5060 of file processor.h. 05061 {
05062 return new ToMassCenterProcessor();
05063 }
|
|
|
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 5544 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(). 05545 {
05546 if (!image) {
05547 LOGWARN("NULL Image");
05548 return;
05549 }
05550
05551 int int_shift_only = params.set_default("int_shift_only",1);
05552 float threshold = params.set_default("threshold",0.0f);
05553 // int positive = params.set_default("positive",0);
05554
05555 if ((float)image->get_attr("sigma")==0.0f) return; // Can't center a constant valued image
05556 if (threshold>(float)image->get_attr("maximum")) {
05557 printf("Warning, centering threshold %1.2f, but image max %1.2f. Adjusting.",threshold,(float)image->get_attr("maximum"));
05558 threshold=(float)image->get_attr("mean")+(float)image->get_attr("sigma");
05559 }
05560
05561 FloatPoint com = image->calc_center_of_mass(threshold);
05562
05563 int nx = image->get_xsize();
05564 int ny = image->get_ysize();
05565 int nz = image->get_zsize();
05566
05567 if (int_shift_only) {
05568 int dx = -(int)(floor(com[0] + 0.5f) - nx / 2);
05569 int dy = -(int)(floor(com[1] + 0.5f) - ny / 2);
05570 int dz = 0;
05571 if (nz > 1) {
05572 dz = -(int)(floor(com[2] + 0.5f) - nz / 2);
05573 }
05574 image->translate(dx, dy, dz);
05575
05576 Transform t;
05577 t.set_trans((float)dx,(float)dy,(float)dz);
05578
05579 if (nz > 1) {
05580 image->set_attr("xform.align3d",&t);
05581 } else {
05582 image->set_attr("xform.align2d",&t);
05583 }
05584 }
05585 else {
05586 float dx = -(com[0] - nx / 2);
05587 float dy = -(com[1] - ny / 2);
05588 float dz = 0;
05589 if (nz > 1) {
05590 dz = -(com[2] - nz / 2);
05591 }
05592 image->translate(dx, dy, dz);
05593
05594 Transform t;
05595 t.set_trans(dx,dy,dz);
05596
05597 if (nz > 1) {
05598 image->set_attr("xform.align3d",&t);
05599 } else {
05600 image->set_attr("xform.align2d",&t);
05601 }
05602 }
05603 }
|
|
|
Definition at line 171 of file processor.cpp. |
1.3.9.1