#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 187 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().
00189 { 00190 00191 //get the scale range 00192 float min = params.set_default("min",0.95f); 00193 float max = params.set_default("max",1.05f); 00194 float step = params.set_default("step",0.01f); 00195 00196 Transform t = Transform(); 00197 t.set_scale(max); 00198 float* oridata = this_img->get_data(); 00199 00200 //get the transform processor and cast to correct factory product 00201 Processor* proc = Factory <Processor>::get("xform", Dict()); 00202 TransformProcessor* xform = dynamic_cast<TransformProcessor*>(proc); 00203 00204 // Using the following method we only create one EMdata object. If I just used the processor, then I would create many EMdata objects 00205 float bestscale = 1.0; 00206 float bestscore = numeric_limits<float>::infinity(); 00207 00208 for(float i = max; i > min; i-=step){ 00209 00210 float* des_data = xform->transform(this_img,t); 00211 this_img->set_data(des_data); 00212 this_img->update(); 00213 00214 //check compairsion 00215 float score = this_img->cmp(cmp_name, to, cmp_params); 00216 if(score < bestscore){ 00217 bestscore = score; 00218 bestscale = i; 00219 } 00220 //clean up scaled image data 00221 delete des_data; 00222 00223 t.set_scale(i); 00224 00225 //reset original data 00226 this_img->set_data(oridata); 00227 } 00228 00229 00230 00231 //Return scaled image 00232 t.set_scale(bestscale); 00233 EMData* result = this_img->process("xform",Dict("transform",&t)); 00234 result->set_attr("scalefactor",bestscale); 00235 if (proc != 0) delete proc; 00236 00237 return result; 00238 00239 }
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] |