This will calculate the dot product for each quadrant of the image and return the worst value.
More...
#include <cmp.h>
|
static const string | NAME = "quadmindot" |
|
This will calculate the dot product for each quadrant of the image and return the worst value.
- Author
- Steve Ludtke (sludt.nosp@m.ke@b.nosp@m.cm.tm.nosp@m.c.ed.nosp@m.u)
- Date
- 2005-07-13
- Parameters
-
negative | Returns -1 * dot product, default true |
normalize | Returns normalized dot product -1.0 - 1.0 |
Definition at line 488 of file cmp.h.
◆ cmp()
float QuadMinDotCmp::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
-
image | The first image to be compared. |
with | The second image to be comppared. |
- Returns
- The comparison result. Smaller better by default
Implements EMAN::Cmp.
Definition at line 988 of file cmp.cpp.
995 int nx=image->get_xsize();
996 int ny=image->get_ysize();
1001 if (negative) negative=-1.0;
else negative=1.0;
1003 double result[4] = { 0,0,0,0 }, sq1[4] = { 0,0,0,0 }, sq2[4] = { 0,0,0,0 } ;
1005 vector<int> image_saved_offsets = image->get_array_offsets();
1006 vector<int> with_saved_offsets = with->get_array_offsets();
1007 image->set_array_offsets(-nx/2,-ny/2);
1008 with->set_array_offsets(-nx/2,-ny/2);
1010 for (
y=-ny/2;
y<ny/2;
y++) {
1011 for (
x=-nx/2;
x<nx/2;
x++) {
1012 int quad=(
x<0?0:1) + (
y<0?0:2);
1013 result[quad]+=(*image)(
x,
y)*(*with)(
x,
y);
1015 sq1[quad]+=(*image)(
x,
y)*(*image)(
x,
y);
1016 sq2[quad]+=(*with)(
x,
y)*(*with)(
x,
y);
1020 image->set_array_offsets(image_saved_offsets);
1021 with->set_array_offsets(with_saved_offsets);
1024 for (i=0; i<4; i++) result[i]/=
sqrt(sq1[i]*sq2[i]);
1026 for (i=0; i<4; i++) result[i]/=nx*ny/4;
1029 float worst=
static_cast<float>(result[0]);
1030 for (i=1; i<4; i++) if (static_cast<float>(result[i])<worst) worst=
static_cast<float>(result[i]);
1033 return (
float) (negative*worst);
void validate_input_args(const EMData *image, const EMData *with) const
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...
EMData * sqrt() const
return square root of current image
#define InvalidValueException(val, desc)
References ENTERFUNC, EXITFUNC, InvalidValueException, EMAN::Cmp::params, EMAN::Dict::set_default(), sqrt(), EMAN::Cmp::validate_input_args(), x, and y.
◆ get_desc()
string EMAN::QuadMinDotCmp::get_desc |
( |
| ) |
const |
|
inlinevirtual |
Implements EMAN::Cmp.
Definition at line 498 of file cmp.h.
500 return "Calculates dot product for each quadrant and returns worst value (default -1 * dot product)";
◆ get_name()
string EMAN::QuadMinDotCmp::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 493 of file cmp.h.
References NAME.
◆ get_param_types()
TypeDict EMAN::QuadMinDotCmp::get_param_types |
( |
| ) |
const |
|
inlinevirtual |
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.
Implements EMAN::Cmp.
Definition at line 508 of file cmp.h.
511 d.put(
"negative",
EMObject::INT,
"If set, returns -1 * dot product. Default = true (smaller is better)");
512 d.put(
"normalize",
EMObject::INT,
"If set, returns normalized dot product -1.0 - 1.0.");
References EMAN::EMObject::INT, and EMAN::TypeDict::put().
◆ NEW()
static Cmp * EMAN::QuadMinDotCmp::NEW |
( |
| ) |
|
|
inlinestatic |
Definition at line 503 of file cmp.h.
505 return new QuadMinDotCmp();
◆ NAME
const string QuadMinDotCmp::NAME = "quadmindot" |
|
static |
The documentation for this class was generated from the following files: