EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::ToMassCenterProcessor Class Reference

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]

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "xform.centerofmass"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

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

Parameters
int_shift_onlyset to 1 only shift by integer, no interpolation

Definition at line 7126 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::ToMassCenterProcessor::get_desc ( ) const
inlinevirtual

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 7141 of file processor.h.

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

◆ get_name()

virtual string EMAN::ToMassCenterProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 7131 of file processor.h.

7132 {
7133 return NAME;
7134 }
static const string NAME
Definition: processor.h:7156

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::ToMassCenterProcessor::get_param_types ( ) const
inlinevirtual

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 7146 of file processor.h.

7147 {
7148 TypeDict d;
7149 d.put("int_shift_only", EMObject::INT, "set to 1 only shift by integer, no interpolation");
7150 d.put("threshold", EMObject::FLOAT, "Only values larger than the threshold are included in the center of mass computation. Default is 0.");
7151 d.put("powercenter", EMObject::INT, "If set, squares pixel values before computing the center. The threshold is with respect to the squared values.");
7152// d.put("positive", EMObject::INT, "uses only densities >0 for the calculatton");
7153 return d;
7154 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ NEW()

static Processor * EMAN::ToMassCenterProcessor::NEW ( )
inlinestatic

Definition at line 7136 of file processor.h.

7137 {
7138 return new ToMassCenterProcessor();
7139 }
ToMassCenterProcessor centers image at center of mass, ignores old dx, dy.
Definition: processor.h:7127

◆ process_inplace()

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
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 7423 of file processor.cpp.

7424{
7425 if (!image) {
7426 LOGWARN("NULL Image");
7427 return;
7428 }
7429
7430 int int_shift_only = params.set_default("int_shift_only",1);
7431 int powercenter = params.set_default("powercenter",0);
7432 float threshold = params.set_default("threshold",0.0f);
7433// int positive = params.set_default("positive",0);
7434
7435 if ((float)image->get_attr("sigma")==0.0f) return; // Can't center a constant valued image
7436 if (threshold>(float)image->get_attr("maximum")) {
7437 printf("Warning, centering threshold %1.2f, but image max %1.2f. Adjusting.",threshold,(float)image->get_attr("maximum"));
7438 threshold=(float)image->get_attr("mean")+(float)image->get_attr("sigma");
7439 }
7440
7441 EMData *tmp = 0;
7442 if (powercenter) { tmp=image; image=tmp->process("math.squared"); } // yes, I know, not very efficient
7443 FloatPoint com = image->calc_center_of_mass(threshold);
7444 if (powercenter) { delete image; image=tmp; }
7445
7446 int nx = image->get_xsize();
7447 int ny = image->get_ysize();
7448 int nz = image->get_zsize();
7449
7450 if (int_shift_only) {
7451 int dx = -(floor(com[0] + 0.5f) - nx / 2);
7452 int dy = -(floor(com[1] + 0.5f) - ny / 2);
7453 int dz = 0;
7454 if (nz > 1) {
7455 dz = -(floor(com[2] + 0.5f) - nz / 2);
7456 }
7457 if (abs(dx)>=nx-1 || abs(dy)>=ny-1 || abs(dz)>=nz) {
7458 printf("ERROR, center of mass outside image\n");
7459 }
7460 else {
7461 image->translate(dx, dy, dz);
7462
7463 Transform t;
7464 t.set_trans((float)dx,(float)dy,(float)dz);
7465
7466 if (nz > 1) {
7467 image->set_attr("xform.align3d",&t);
7468 } else {
7469 image->set_attr("xform.align2d",&t);
7470 }
7471 }
7472 }
7473 else {
7474 float dx = -(com[0] - nx / 2);
7475 float dy = -(com[1] - ny / 2);
7476 float dz = 0;
7477 if (nz > 1) {
7478 dz = -(com[2] - nz / 2);
7479 }
7480 if (fabs(dx)>=nx-1 || fabs(dy)>=ny-2 || fabs(dz)>=nz) {
7481 printf("ERROR, center of mass outside image\n");
7482 }
7483 else {
7484 image->translate(dx, dy, dz);
7485
7486 Transform t;
7487 t.set_trans(dx,dy,dz);
7488
7489 if (nz > 1) {
7490 image->set_attr("xform.align3d",&t);
7491 } else {
7492 image->set_attr("xform.align2d",&t);
7493 }
7494 }
7495 }
7496}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
void translate(float dx, float dy, float dz)
Translate this image.
Definition: emdata.cpp:904
FloatPoint defines a float-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:278
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
void set_trans(const float &x, const float &y, const float &z=0)
Set the post translation component.
Definition: transform.cpp:1036
#define LOGWARN
Definition: log.h:53

References LOGWARN, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::Transform::set_trans(), and EMAN::EMData::translate().

Member Data Documentation

◆ NAME

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

Definition at line 7156 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: