#include <aligner.h>
Inheritance diagram for EMAN::ScaleAligner:
Public Member Functions | |
virtual EMData * | align (EMData *this_img, EMData *to_img, const string &cmp_name="dot", const Dict &cmp_params=Dict()) const |
To align 'this_img' with another image passed in through its parameters. | |
virtual EMData * | align (EMData *this_img, EMData *to_img) const |
virtual string | get_name () const |
Get the Aligner's name. | |
virtual string | get_desc () const |
virtual TypeDict | get_param_types () const |
Static Public Member Functions | |
static Aligner * | NEW () |
Static Public Attributes | |
static const string | NAME = "scale" |
To scale one image to another in real space
min | Minimum scaling (default: 0.95) | |
max | aximum scaling (default: 1.05) | |
step | Scaling step (default: 0.01) |
Definition at line 195 of file aligner.h.
virtual EMData* EMAN::ScaleAligner::align | ( | EMData * | this_img, | |
EMData * | to_img | |||
) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 201 of file aligner.h.
References align().
00202 { 00203 return align(this_img, to_img, "dot", Dict()); 00204 }
EMData * ScaleAligner::align | ( | EMData * | this_img, | |
EMData * | to_img, | |||
const string & | cmp_name = "dot" , |
|||
const Dict & | cmp_params = Dict() | |||
) | const [virtual] |
To align 'this_img' with another image passed in through its parameters.
The alignment uses a user-given comparison method to compare the two images. If none is given, a default one is used.
this_img | The image to be compared. | |
to_img | 'this_img" is aligned with 'to_img'. | |
cmp_name | The comparison method to compare the two images. | |
cmp_params | The parameter dictionary for comparison method. |
Implements EMAN::Aligner.
Definition at line 190 of file aligner.cpp.
References EMAN::EMData::cmp(), EMAN::EMData::get_data(), max, min, EMAN::Aligner::params, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::EMData::set_data(), EMAN::Dict::set_default(), t, and EMAN::EMData::update().
Referenced by align().
00192 { 00193 00194 //get the scale range 00195 float min = params.set_default("min",0.95f); 00196 float max = params.set_default("max",1.05f); 00197 float step = params.set_default("step",0.01f); 00198 00199 Transform t = Transform(); 00200 t.set_scale(max); 00201 float* oridata = this_img->get_data(); 00202 00203 //get the transform processor and cast to correct factory product 00204 Processor* proc = Factory <Processor>::get("xform", Dict()); 00205 TransformProcessor* xform = dynamic_cast<TransformProcessor*>(proc); 00206 00207 // Using the following method we only create one EMdata object. If I just used the processor, then I would create many EMdata objects 00208 float bestscale = 1.0; 00209 float bestscore = 1.0e37; 00210 00211 for(float i = max; i > min; i-=step){ 00212 00213 float* des_data = xform->transform(this_img,t); 00214 this_img->set_data(des_data); 00215 this_img->update(); 00216 00217 //check compairsion 00218 float score = this_img->cmp(cmp_name, to, cmp_params); 00219 if(score < bestscore){ 00220 bestscore = score; 00221 bestscale = i; 00222 } 00223 //clean up scaled image data 00224 delete des_data; 00225 00226 t.set_scale(i); 00227 00228 //reset original data 00229 this_img->set_data(oridata); 00230 } 00231 00232 00233 00234 //Return scaled image 00235 t.set_scale(bestscale); 00236 EMData* result = this_img->process("xform",Dict("transform",&t)); 00237 result->set_attr("scalefactor",bestscale); 00238 if (proc != 0) delete proc; 00239 00240 return result; 00241 00242 }
virtual string EMAN::ScaleAligner::get_desc | ( | ) | const [inline, virtual] |
virtual string EMAN::ScaleAligner::get_name | ( | ) | const [inline, virtual] |
virtual TypeDict EMAN::ScaleAligner::get_param_types | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 221 of file aligner.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
00222 { 00223 TypeDict d; 00224 d.put("min", EMObject::FLOAT, "Minimum scaling (default: 0.95)"); 00225 d.put("max", EMObject::FLOAT, "Maximum scaling (default: 1.05)"); 00226 d.put("step", EMObject::FLOAT, "Scaling step (default: 0.01)"); 00227 return d; 00228 }
static Aligner* EMAN::ScaleAligner::NEW | ( | ) | [inline, static] |
const string ScaleAligner::NAME = "scale" [static] |