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

XYZCmp is a cmp template for defining new cmps. More...

#include <cmp_template.h>

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

Public Member Functions

float cmp (EMData *image, EMData *with) const
 To compare 'image' with another image passed in through its parameters. More...
 
string get_name () const
 Get the Cmp's name. More...
 
string get_desc () const
 
TypeDict get_param_types () const
 Add your cmp parameter names and types in get_param_types(). More...
 
- Public Member Functions inherited from EMAN::Cmp
virtual ~Cmp ()
 
virtual Dict get_params () const
 Get the Cmp parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the Cmp parameters using a key/value dictionary. More...
 

Static Public Member Functions

static CmpNEW ()
 

Static Public Attributes

static const string NAME = "middle"
 

Additional Inherited Members

- Protected Member Functions inherited from EMAN::Cmp
void validate_input_args (const EMData *image, const EMData *with) const
 
- Protected Attributes inherited from EMAN::Cmp
Dict params
 

Detailed Description

XYZCmp is a cmp template for defining new cmps.

Please add your own code at the proper place.

1) Replace all 'XYZ' with your new cmp name. 2) Define the cmp parameter names and types in get_param_types(). 3) Implement the cmp in XYZCmp::cmp().

Definition at line 48 of file cmp_template.h.

Member Function Documentation

◆ cmp()

float XYZCmp::cmp ( EMData image,
EMData with 
) const
virtual

To compare 'image' with another image passed in through its parameters.

An optional transformation may be used to transform the 2 images.

Parameters
imageThe first image to be compared.
withThe second image to be comppared.
Returns
The comparison result. Smaller better by default

Implements EMAN::Cmp.

Definition at line 40 of file cmp_template.cpp.

41{
42 validate_input_args(image, with);
43
44#if 0
45 int param1 = params["param1"];
46 float param2 = params["param2"];
47 // do something
48#endif
49 int nx=image->get_xsize();
50 int ny=image->get_ysize();
51
52 double ret=0;
53 for (int i=nx/4; i<nx*3/4; i++) {
54 for (int j=ny/4; j<ny*3/4; j++) {
55 ret+=image->get_value_at(i,j)*with->get_value_at(i,j);
56 }
57 }
58
59 return (float) ret;
60}
void validate_input_args(const EMData *image, const EMData *with) const
Definition: cmp.cpp:81
Dict params
Definition: cmp.h:132

References EMAN::Cmp::params, and EMAN::Cmp::validate_input_args().

◆ get_desc()

string EMAN::XYZCmp::get_desc ( ) const
inlinevirtual

Implements EMAN::Cmp.

Definition at line 58 of file cmp_template.h.

59 {
60 return "dot product using the center of the image";
61 }

◆ get_name()

string EMAN::XYZCmp::get_name ( ) const
inlinevirtual

Get the Cmp's name.

Each Cmp is identified by a unique name.

Returns
The Cmp's name.

Implements EMAN::Cmp.

Definition at line 53 of file cmp_template.h.

54 {
55 return NAME;
56 }
static const string NAME
Definition: cmp_template.h:85

References NAME.

◆ get_param_types()

TypeDict EMAN::XYZCmp::get_param_types ( ) const
inlinevirtual

Add your cmp parameter names and types in get_param_types().

For available parameter types, please refer class EMObject.

As an example, XYZCmp has 3 parameters: EMData *with; int param1; float param2;

Implements EMAN::Cmp.

Definition at line 77 of file cmp_template.h.

78 {
79 TypeDict d;
80 d.put("radius", EMObject::INT);
81 d.put("param2", EMObject::FLOAT);
82 return d;
83 }

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

◆ NEW()

static Cmp * EMAN::XYZCmp::NEW ( )
inlinestatic

Definition at line 63 of file cmp_template.h.

64 {
65 return new XYZCmp();
66 }

Member Data Documentation

◆ NAME

const string XYZCmp::NAME = "middle"
static

Definition at line 85 of file cmp_template.h.

Referenced by get_name().


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