Public Member Functions | Protected Attributes | List of all members
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

Public Member Functions

 ScaleAlignerABS (const string &ba)
 Constructor to initialize the basealigner string. More...
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 More...
- Public Member Functions inherited from EMAN::Aligner
virtual ~Aligner ()
virtual EMDataalign (EMData *this_img, EMData *to_img) const =0
virtual EMDataalign (EMData *this_img, EMData *to_img, const string &cmp_name, const Dict &cmp_params) const =0
 To align 'this_img' with another image passed in through its parameters. More...
virtual string get_name () const =0
 Get the Aligner's name. More...
virtual string get_desc () const =0
virtual Dict get_params () const
 Get the Aligner parameters in a key/value dictionary. More...
virtual void set_params (const Dict &new_params)
 Set the Aligner parameters using a key/value dictionary. More...
virtual TypeDict get_param_types () const =0
virtual vector< Dictxform_align_nbest (EMData *this_img, EMData *to_img, const unsigned int nsoln, const string &cmp_name, const Dict &cmp_params) const
 This function first added in the context of the 3D aligners used by e2tomohunter: which wants the n best solutions, as opposed to just the best. More...

Protected Attributes

const string basealigner
Dict basealigner_params
- Protected Attributes inherited from EMAN::Aligner
Dict 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 166 of file aligner.h.

Constructor & Destructor Documentation

◆ ScaleAlignerABS()

EMAN::ScaleAlignerABS::ScaleAlignerABS ( const string &  ba)

Constructor to initialize the basealigner string.

Definition at line 170 of file aligner.h.

170 : basealigner(ba)
171 {
172 }
const string basealigner
Definition: aligner.h:179

Member Function Documentation

◆ align_using_base()

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 141 of file aligner.cpp.

144 //get the scale range
145 float min = params.set_default("min",0.95f);
146 float max = params.set_default("max",1.05f);
147 float step = params.set_default("step",0.01f);
149 // crate the starting transform
150 Transform t = Transform();
151 t.set_scale(max);
153 //save orignal data
154 float* oridata = this_img->get_data();
156 //get the transform processor and cast to correct factory product
157 Processor* proc = Factory <Processor>::get("xform", Dict());
158 TransformProcessor* xform = dynamic_cast<TransformProcessor*>(proc);
160 // Using the following method we only create one EMdata object. If I just used the processor, then I would create many EMdata objects
161 EMData* result = 0;
162// float bestscore = numeric_limits<float>::infinity();
163 float bestscore = 1.0e37;
165 for(float i = max; i > min; i-=step){
167 //scale the image
168 float* des_data = xform->transform(this_img,t);
169 this_img->set_data(des_data);
170 this_img->update();
172 //check compairsion
173 EMData* aligned = this_img->align(basealigner, to, basealigner_params, cmp_name, cmp_params);
174 float score = aligned->cmp(cmp_name, to, cmp_params);
175 if(score < bestscore){
176 bestscore = score;
177 //If we just reassign w/o cleaing up we will get memory leaks!
178 if(result != 0) delete result;
179 result = aligned;
180 Transform *tt=(Transform*)(result->get_attr("xform.align2d"));
181 tt->set_scale(i);
182 result->set_attr("xform.align2d",tt);
183// result->set_attr("scalefactor",i); // I don't know why this was done instead of updating the transform, but it breaks a bunch of things
184 }else{
185 delete aligned;
186 }
187 //clean up scaled image data
188 delete des_data;
190 t.set_scale(i);
192 //reset original data
193 this_img->set_data(oridata);
194 }
196 if (!result) throw UnexpectedBehaviorException("Alignment score is infinity! Something is seriously wrong with the data!");
197 if (proc != 0) delete proc;
199 return result;
Dict params
Definition: aligner.h:147
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
Factory is used to store objects to create new instances.
Definition: emobject.h:725
Typical usage of Processors are as follows:
Definition: processor.h:90
Transform the image using a Transform object.
Definition: processor.h:2826
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
void set_scale(const float &scale)
Set the scale.
Definition: transform.cpp:1123
#define UnexpectedBehaviorException(desc)
Definition: exception.h:400

References basealigner, basealigner_params, EMAN::Aligner::params, EMAN::Dict::set_default(), EMAN::Transform::set_scale(), and UnexpectedBehaviorException.

Member Data Documentation

◆ basealigner

const string EMAN::ScaleAlignerABS::basealigner

Definition at line 179 of file aligner.h.

Referenced by align_using_base().

◆ basealigner_params

Dict EMAN::ScaleAlignerABS::basealigner_params

Definition at line 180 of file aligner.h.

Referenced by align_using_base().

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