Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::ToMassCenterProcessor Class Reference
[unit test in Python]

ToMassCenterProcessor centers image at center of mass, ignores old dx, dy. More...

#include <processor.h>

Inheritance diagram for EMAN::ToMassCenterProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::ToMassCenterProcessor:

Collaboration graph
[legend]
List of all members.

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

ProcessorNEW ()

Static Public Attributes

const string NAME = "xform.centerofmass"

Detailed Description

ToMassCenterProcessor centers image at center of mass, ignores old dx, dy.

Parameters:
int_shift_only set to 1 only shift by integer, no interpolation

Definition at line 4994 of file processor.h.


Member Function Documentation

virtual string EMAN::ToMassCenterProcessor::get_desc  )  const [inline, virtual]
 

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 5009 of file processor.h.

05010                 {
05011                         return "ToMassCenterProcessor centers image at center of mass, with a threshold. Only values higher than the threshold are considered.";
05012                 }

virtual string EMAN::ToMassCenterProcessor::get_name  )  const [inline, virtual]
 

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 4999 of file processor.h.

05000                 {
05001                         return NAME;
05002                 }

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.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 5014 of file processor.h.

References EMAN::TypeDict::put().

05015                 {
05016                         TypeDict d;
05017                         d.put("int_shift_only", EMObject::INT, "set to 1 only shift by integer, no interpolation");
05018                         d.put("threshold", EMObject::FLOAT, "Only values larger than the threshold are included in the center of mass computation. Default is 0.");
05019 //                      d.put("positive", EMObject::INT, "uses only densities >0 for the calculatton");
05020                         return d;
05021                 }

Processor* EMAN::ToMassCenterProcessor::NEW  )  [inline, static]
 

Definition at line 5004 of file processor.h.

05005                 {
05006                         return new ToMassCenterProcessor();
05007                 }

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.

Parameters:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 5546 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().

05547 {
05548         if (!image) {
05549                 LOGWARN("NULL Image");
05550                 return;
05551         }
05552 
05553         int int_shift_only = params.set_default("int_shift_only",1);
05554         float threshold = params.set_default("threshold",0.0f);
05555 //      int positive = params.set_default("positive",0);
05556 
05557         if ((float)image->get_attr("sigma")==0.0f) return;              // Can't center a constant valued image
05558 
05559         FloatPoint com = image->calc_center_of_mass(threshold);
05560 
05561         int nx = image->get_xsize();
05562         int ny = image->get_ysize();
05563         int nz = image->get_zsize();
05564 
05565         if (int_shift_only) {
05566                 int dx = -(int)(floor(com[0] + 0.5f) - nx / 2);
05567                 int dy = -(int)(floor(com[1] + 0.5f) - ny / 2);
05568                 int dz = 0;
05569                 if (nz > 1) {
05570                         dz = -(int)(floor(com[2] + 0.5f) - nz / 2);
05571                 }
05572                 image->translate(dx, dy, dz);
05573 
05574                 Transform t;
05575                 t.set_trans((float)dx,(float)dy,(float)dz);
05576 
05577                 if (nz > 1) {
05578                         image->set_attr("xform.align3d",&t);
05579                 } else {
05580                         image->set_attr("xform.align2d",&t);
05581                 }
05582         }
05583         else {
05584                 float dx = -(com[0] - nx / 2);
05585                 float dy = -(com[1] - ny / 2);
05586                 float dz = 0;
05587                 if (nz > 1) {
05588                         dz = -(com[2] - nz / 2);
05589                 }
05590                 image->translate(dx, dy, dz);
05591 
05592                 Transform t;
05593                 t.set_trans(dx,dy,dz);
05594 
05595                 if (nz > 1) {
05596                         image->set_attr("xform.align3d",&t);
05597                 } else {
05598                         image->set_attr("xform.align2d",&t);
05599                 }
05600         }
05601 }


Member Data Documentation

const string ToMassCenterProcessor::NAME = "xform.centerofmass" [static]
 

Definition at line 169 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Mar 10 23:00:50 2011 for EMAN2 by  doxygen 1.3.9.1