#include <aligner.h>
Inheritance diagram for EMAN::ScaleAlignerABS:
Public Member Functions | |
ScaleAlignerABS (const string &ba) | |
Constructor to initialize the basealigner string. | |
EMData * | align_using_base (EMData *this_img, EMData *to_img, const string &cmp_name="dot", const Dict &cmp_params=Dict()) const |
implmentation of the scale alignment using the base aligner set in set_base_aligner | |
Protected Attributes | |
const string | basealigner |
Dict | basealigner_params |
Hence this class is not be be initialized To use, inherit this class and set the base aligner name This stragtegy uses the Template design pattern
Definition at line 170 of file aligner.h.
EMAN::ScaleAlignerABS::ScaleAlignerABS | ( | const string & | ba | ) | [inline] |
Constructor to initialize the basealigner string.
Definition at line 174 of file aligner.h.
00174 : basealigner(ba) 00175 { 00176 }
EMData * ScaleAlignerABS::align_using_base | ( | EMData * | this_img, | |
EMData * | to_img, | |||
const string & | cmp_name = "dot" , |
|||
const Dict & | cmp_params = Dict() | |||
) | const |
implmentation of the scale alignment using the base aligner set in set_base_aligner
Definition at line 129 of file aligner.cpp.
References EMAN::EMData::align(), basealigner, basealigner_params, EMAN::EMData::cmp(), EMAN::EMData::get_data(), max, min, EMAN::Aligner::params, EMAN::EMData::set_attr(), EMAN::EMData::set_data(), EMAN::Dict::set_default(), t, UnexpectedBehaviorException, and EMAN::EMData::update().
Referenced by EMAN::RotateTranslateFlipScaleAlignerIterative::align(), EMAN::RotateTranslateFlipScaleAligner::align(), EMAN::RotateTranslateScaleAligner::align(), and EMAN::RotateTranslateScaleAlignerIterative::align().
00131 { 00132 //get the scale range 00133 float min = params.set_default("min",0.95f); 00134 float max = params.set_default("max",1.05f); 00135 float step = params.set_default("step",0.01f); 00136 00137 // crate the starting transform 00138 Transform t = Transform(); 00139 t.set_scale(max); 00140 00141 //save orignal data 00142 float* oridata = this_img->get_data(); 00143 00144 //get the transform processor and cast to correct factory product 00145 Processor* proc = Factory <Processor>::get("xform", Dict()); 00146 TransformProcessor* xform = dynamic_cast<TransformProcessor*>(proc); 00147 00148 // Using the following method we only create one EMdata object. If I just used the processor, then I would create many EMdata objects 00149 EMData* result = 0; 00150 float bestscore = numeric_limits<float>::infinity(); 00151 00152 for(float i = max; i > min; i-=step){ 00153 00154 //scale the image 00155 float* des_data = xform->transform(this_img,t); 00156 this_img->set_data(des_data); 00157 this_img->update(); 00158 00159 //check compairsion 00160 EMData* aligned = this_img->align(basealigner, to, basealigner_params, cmp_name, cmp_params); 00161 float score = aligned->cmp(cmp_name, to, cmp_params); 00162 if(score < bestscore){ 00163 bestscore = score; 00164 //If we just reassign w/o cleaing up we will get memory leaks! 00165 if(result != 0) delete result; 00166 result = aligned; 00167 result->set_attr("scalefactor",i); 00168 }else{ 00169 delete aligned; 00170 } 00171 //clean up scaled image data 00172 delete des_data; 00173 00174 t.set_scale(i); 00175 00176 //reset original data 00177 this_img->set_data(oridata); 00178 } 00179 00180 if (!result) throw UnexpectedBehaviorException("Alignment score is infinity! Something is seriously wrong with the data!"); 00181 if (proc != 0) delete proc; 00182 00183 return result; 00184 00185 };
const string EMAN::ScaleAlignerABS::basealigner [protected] |
Dict EMAN::ScaleAlignerABS::basealigner_params [protected] |
Definition at line 184 of file aligner.h.
Referenced by EMAN::RotateTranslateFlipScaleAlignerIterative::align(), EMAN::RotateTranslateFlipScaleAligner::align(), EMAN::RotateTranslateScaleAligner::align(), EMAN::RotateTranslateScaleAlignerIterative::align(), and align_using_base().