#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 | |
Aligner * | NEW () |
Static Public Attributes | |
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.
|
Implements EMAN::Aligner. Definition at line 201 of file aligner.h. References align(). 00202 { 00203 return align(this_img, to_img, "dot", Dict()); 00204 }
|
|
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.
Implements EMAN::Aligner. Definition at line 187 of file aligner.cpp. References EMAN::EMData::cmp(), EMAN::EMData::get_data(), max, min, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::EMData::set_data(), EMAN::Dict::set_default(), EMAN::Transform::set_scale(), t, EMAN::TransformProcessor::transform(), and EMAN::EMData::update(). 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 }
|
|
Implements EMAN::Aligner. Definition at line 211 of file aligner.h. 00212 { 00213 return "Performs real space scale alignment"; 00214 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 206 of file aligner.h. 00207 {
00208 return NAME;
00209 }
|
|
Implements EMAN::Aligner. Definition at line 221 of file aligner.h. References 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 }
|
|
Definition at line 216 of file aligner.h. 00217 { 00218 return new ScaleAligner(); 00219 }
|
|
Definition at line 87 of file aligner.cpp. |