EMAN2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EMAN::Cmp Class Referenceabstract

Cmp class defines image comparison method. More...

#include <cmp.h>

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

Public Member Functions

virtual ~Cmp ()
 
virtual float cmp (EMData *image, EMData *with) const =0
 To compare 'image' with another image passed in through its parameters. More...
 
virtual string get_name () const =0
 Get the Cmp's name. More...
 
virtual string get_desc () const =0
 
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...
 
virtual TypeDict get_param_types () const =0
 Get Cmp parameter information in a dictionary. More...
 

Protected Member Functions

void validate_input_args (const EMData *image, const EMData *with) const
 

Protected Attributes

Dict params
 

Detailed Description

Cmp class defines image comparison method.

Using default arguments, smaller values indicate more similar images.

Cmp class is the base comparison class. Each specific comparison class is a subclass of Cmp, and must have a unique name. The name is used to create a new Cmp instance or call a Cmp.

All Cmp classes in EMAN are managed by a Factory pattern. So
each Cmp class must define:
  - a unique name to idenfity itself in the factory.
  - a static method to register itself in the factory.

Typical usage of Cmp:

Definition at line 81 of file cmp.h.

Constructor & Destructor Documentation

◆ ~Cmp()

virtual EMAN::Cmp::~Cmp ( )
inlinevirtual

Definition at line 84 of file cmp.h.

85 {
86 }

Member Function Documentation

◆ cmp()

virtual float EMAN::Cmp::cmp ( EMData image,
EMData with 
) const
pure 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

Implemented in EMAN::CccCmp, EMAN::LodCmp, EMAN::SqEuclideanCmp, EMAN::DotCmp, EMAN::TomoCccCmp, EMAN::TomoWedgeCccCmp, EMAN::TomoWedgeFscCmp, EMAN::TomoFscCmp, EMAN::QuadMinDotCmp, EMAN::OptSubCmp, EMAN::OptVarianceCmp, EMAN::PhaseCmp, EMAN::FRCCmp, EMAN::VerticalCmp, and EMAN::XYZCmp.

Referenced by refalifn(), refalifn3dquat(), symquat(), EMAN::RT3DGridAligner::xform_align_nbest(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DSymmetryAligner::xform_align_nbest().

◆ get_desc()

virtual string EMAN::Cmp::get_desc ( ) const
pure virtual

◆ get_name()

virtual string EMAN::Cmp::get_name ( ) const
pure virtual

◆ get_param_types()

virtual TypeDict EMAN::Cmp::get_param_types ( ) const
pure virtual

Get Cmp 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.

Implemented in EMAN::CccCmp, EMAN::LodCmp, EMAN::SqEuclideanCmp, EMAN::DotCmp, EMAN::TomoCccCmp, EMAN::TomoWedgeCccCmp, EMAN::TomoWedgeFscCmp, EMAN::TomoFscCmp, EMAN::QuadMinDotCmp, EMAN::OptSubCmp, EMAN::OptVarianceCmp, EMAN::PhaseCmp, EMAN::FRCCmp, EMAN::VerticalCmp, and EMAN::XYZCmp.

◆ get_params()

virtual Dict EMAN::Cmp::get_params ( ) const
inlinevirtual

Get the Cmp parameters in a key/value dictionary.

Returns
A key/value pair dictionary containing the parameters.

Definition at line 108 of file cmp.h.

109 {
110 return params;
111 }

References params.

◆ set_params()

virtual void EMAN::Cmp::set_params ( const Dict new_params)
inlinevirtual

Set the Cmp parameters using a key/value dictionary.

Parameters
new_paramsA dictionary containing the new parameters.

Definition at line 116 of file cmp.h.

117 {
118 params = new_params;
119 }

References params.

◆ validate_input_args()

void Cmp::validate_input_args ( const EMData image,
const EMData with 
) const
protected

Definition at line 81 of file cmp.cpp.

82{
83
84#ifdef EMAN2_USING_CUDA
85 if (image->getcudarwdata() && with->getcudarwdata()) {
86 //no need for futher checking, which will induce an expensive copy from device to host
87 return;
88 }
89#endif
90 if (!image) {
91 throw NullPointerException("compared image");
92 }
93 if (!with) {
94 throw NullPointerException("compare-with image");
95 }
96
97 if (!EMUtil::is_same_size(image, with)) {
98 throw ImageFormatException( "images not same size");
99 }
100
101 float *d1 = image->get_data();
102 if (!d1) {
103 throw NullPointerException("image contains no data");
104 }
105
106 float *d2 = with->get_data();
107 if (!d2) {
108 throw NullPointerException("compare-with image data");
109 }
110}
static bool is_same_size(const EMData *image1, const EMData *image2)
Check whether two EMData images are of the same size.
Definition: emutil.cpp:1224
#define ImageFormatException(desc)
Definition: exception.h:147
#define NullPointerException(desc)
Definition: exception.h:241

References ImageFormatException, EMAN::EMUtil::is_same_size(), and NullPointerException.

Referenced by EMAN::CccCmp::cmp(), EMAN::LodCmp::cmp(), EMAN::SqEuclideanCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::QuadMinDotCmp::cmp(), EMAN::OptSubCmp::cmp(), EMAN::OptVarianceCmp::cmp(), EMAN::FRCCmp::cmp(), and EMAN::XYZCmp::cmp().

Member Data Documentation

◆ params

Dict EMAN::Cmp::params
mutableprotected

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