EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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]

List of all members.

Public Member Functions

float cmp (EMData *image, EMData *with) const
 To compare 'image' with another image passed in through its parameters.
string get_name () const
 Get the Cmp's name.
string get_desc () const
TypeDict get_param_types () const
 Add your cmp parameter names and types in get_param_types().

Static Public Member Functions

static CmpNEW ()

Static Public Attributes

static const string NAME = "middle"

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

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.

References EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), nx, ny, EMAN::Cmp::params, and EMAN::Cmp::validate_input_args().

{
        validate_input_args(image, with);

#if 0
        int param1 = params["param1"];
        float param2 = params["param2"];
        // do something
#endif
        int nx=image->get_xsize();
        int ny=image->get_ysize();
        
        double ret=0;
        for (int i=nx/4; i<nx*3/4; i++) {
                for (int j=ny/4; j<ny*3/4; j++) {
                        ret+=image->get_value_at(i,j)*with->get_value_at(i,j);
                }
        }

        return (float) ret;
}
string EMAN::XYZCmp::get_desc ( ) const [inline, virtual]

Implements EMAN::Cmp.

Definition at line 58 of file cmp_template.h.

                {
                        return "dot product using the center of the image";
                }
string EMAN::XYZCmp::get_name ( ) const [inline, virtual]

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.

References NAME.

                {
                        return NAME;
                }
TypeDict EMAN::XYZCmp::get_param_types ( ) const [inline, virtual]

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.

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

                {
                        TypeDict d;
                          d.put("radius", EMObject::INT);
                          d.put("param2", EMObject::FLOAT);
                          return d;
                }
static Cmp* EMAN::XYZCmp::NEW ( ) [inline, static]

Definition at line 63 of file cmp_template.h.

                {
                        return new XYZCmp();
                }

Member Data Documentation

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: