EMAN::ScaleAlignerABS Class Reference

This is an ABS for use in constructing, rt_scale, rt_flip, etc scale aligners. More...

#include <aligner.h>

Inheritance diagram for EMAN::ScaleAlignerABS:

Inheritance graph
[legend]
Collaboration diagram for EMAN::ScaleAlignerABS:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ScaleAlignerABS (const string &ba)
 Constructor to initialize the basealigner string.
EMDataalign_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

Detailed Description

This is an ABS for use in constructing, rt_scale, rt_flip, etc scale aligners.

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.


Constructor & Destructor Documentation

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                  }


Member Function Documentation

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 131 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().

00133 {
00134         //get the scale range
00135         float min =  params.set_default("min",0.95f);
00136         float max = params.set_default("max",1.05f);
00137         float step = params.set_default("step",0.01f);
00138         
00139         // crate the starting transform
00140         Transform t = Transform();
00141         t.set_scale(max);
00142         
00143         //save orignal data
00144         float* oridata = this_img->get_data();
00145         
00146         //get the transform processor and cast to correct factory product
00147         Processor* proc = Factory <Processor>::get("xform", Dict());
00148         TransformProcessor* xform = dynamic_cast<TransformProcessor*>(proc);
00149         
00150         // Using the following method we only create one EMdata object. If I just used the processor, then I would create many EMdata objects
00151         EMData* result = 0;
00152 //      float bestscore = numeric_limits<float>::infinity();
00153         float bestscore = 1.0e37;
00154         
00155         for(float i = max; i > min; i-=step){
00156                 
00157                 //scale the image
00158                 float* des_data = xform->transform(this_img,t);
00159                 this_img->set_data(des_data);
00160                 this_img->update();
00161                 
00162                 //check compairsion
00163                 EMData* aligned = this_img->align(basealigner, to, basealigner_params, cmp_name, cmp_params);
00164                 float score = aligned->cmp(cmp_name, to, cmp_params);
00165                 if(score < bestscore){
00166                         bestscore = score;
00167                         //If we just reassign w/o cleaing up we will get memory leaks!
00168                         if(result != 0) delete result;
00169                         result = aligned;
00170                         result->set_attr("scalefactor",i);
00171                 }else{
00172                         delete aligned;
00173                 }
00174                 //clean up scaled image data
00175                 delete des_data;
00176 
00177                 t.set_scale(i);
00178                 
00179                 //reset original data
00180                 this_img->set_data(oridata);
00181         }       
00182         
00183         if (!result) throw UnexpectedBehaviorException("Alignment score is infinity! Something is seriously wrong with the data!");
00184         if (proc != 0) delete proc;
00185         
00186         return result;  
00187         
00188 };


Member Data Documentation

const string EMAN::ScaleAlignerABS::basealigner [protected]

Definition at line 183 of file aligner.h.

Referenced by align_using_base().

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().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 12:42:34 2013 for EMAN2 by  doxygen 1.4.7