Public Member Functions | Protected Attributes
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
Collaboration diagram for EMAN::ScaleAlignerABS:
Collaboration graph

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.

                                                   : basealigner(ba)

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(), EMAN::Transform::set_scale(), t, UnexpectedBehaviorException, and EMAN::EMData::update().

Referenced by EMAN::RotateTranslateFlipScaleAlignerIterative::align(), EMAN::RotateTranslateFlipScaleAligner::align(), EMAN::RotateTranslateScaleAligner::align(), and EMAN::RotateTranslateScaleAlignerIterative::align().

        //get the scale range
        float min =  params.set_default("min",0.95f);
        float max = params.set_default("max",1.05f);
        float step = params.set_default("step",0.01f);
        // crate the starting transform
        Transform t = Transform();
        //save orignal data
        float* oridata = this_img->get_data();
        //get the transform processor and cast to correct factory product
        Processor* proc = Factory <Processor>::get("xform", Dict());
        TransformProcessor* xform = dynamic_cast<TransformProcessor*>(proc);
        // Using the following method we only create one EMdata object. If I just used the processor, then I would create many EMdata objects
        EMData* result = 0;
//      float bestscore = numeric_limits<float>::infinity();
        float bestscore = 1.0e37;
        for(float i = max; i > min; i-=step){
                //scale the image
                float* des_data = xform->transform(this_img,t);
                //check compairsion
                EMData* aligned = this_img->align(basealigner, to, basealigner_params, cmp_name, cmp_params);
                float score = aligned->cmp(cmp_name, to, cmp_params);
                if(score < bestscore){
                        bestscore = score;
                        //If we just reassign w/o cleaing up we will get memory leaks!
                        if(result != 0) delete result;
                        result = aligned;
                        delete aligned;
                //clean up scaled image data
                delete des_data;

                //reset original data
        if (!result) throw UnexpectedBehaviorException("Alignment score is infinity! Something is seriously wrong with the data!");
        if (proc != 0) delete proc;
        return result;  

Member Data Documentation

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

Definition at line 183 of file aligner.h.

Referenced by align_using_base().

The documentation for this class was generated from the following files: