EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::ScaleAligner Class Reference

Scale aligner. More...

#include <aligner.h>

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

List of all members.

Public Member Functions

virtual EMDataalign (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 EMDataalign (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

static AlignerNEW ()

Static Public Attributes

static const string NAME = "scale"

Detailed Description

Scale aligner.

To scale one image to another in real space

Parameters:
minMinimum scaling (default: 0.95)
maxaximum scaling (default: 1.05)
stepScaling step (default: 0.01)
Author:
John Flanagan
Date:
March 2012

Definition at line 195 of file aligner.h.


Member Function Documentation

EMData * ScaleAligner::align ( EMData this_img,
EMData to_img,
const string &  cmp_name = "dot",
const Dict cmp_params = Dict() 
) const [virtual]

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.

Parameters:
this_imgThe image to be compared.
to_img'this_img" is aligned with 'to_img'.
cmp_nameThe comparison method to compare the two images.
cmp_paramsThe parameter dictionary for comparison method.
Returns:
The aligned image.

Implements EMAN::Aligner.

Definition at line 190 of file aligner.cpp.

References EMAN::EMData::cmp(), EMAN::EMData::get_data(), max, min, EMAN::Aligner::params, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::EMData::set_data(), EMAN::Dict::set_default(), EMAN::Transform::set_scale(), t, and EMAN::EMData::update().

Referenced by 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);
        
        Transform t = Transform();
        t.set_scale(max);
        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
        float bestscale = 1.0;
        float bestscore = 1.0e37;

        for(float i = max; i > min; i-=step){
                        
                float* des_data = xform->transform(this_img,t);
                this_img->set_data(des_data);
                this_img->update();
                
                //check compairsion
                float score = this_img->cmp(cmp_name, to, cmp_params);
                if(score < bestscore){
                        bestscore = score;
                        bestscale = i;
                }
                //clean up scaled image data
                delete des_data;
                
                t.set_scale(i);
                
                //reset original data
                this_img->set_data(oridata);
        }


        
        //Return scaled image
        t.set_scale(bestscale);
        EMData* result = this_img->process("xform",Dict("transform",&t));
        result->set_attr("scalefactor",bestscale);
        if (proc != 0) delete proc;
        
        return result;
        
}
virtual EMData* EMAN::ScaleAligner::align ( EMData this_img,
EMData to_img 
) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 201 of file aligner.h.

References align().

                {
                        return align(this_img, to_img, "dot", Dict());
                }
virtual string EMAN::ScaleAligner::get_desc ( ) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 211 of file aligner.h.

                {
                        return "Performs real space scale alignment";
                }
virtual string EMAN::ScaleAligner::get_name ( ) const [inline, virtual]

Get the Aligner's name.

Each Aligner is identified by a unique name.

Returns:
The Aligner's name.

Implements EMAN::Aligner.

Definition at line 206 of file aligner.h.

References NAME.

                {
                        return NAME;
                }
virtual TypeDict EMAN::ScaleAligner::get_param_types ( ) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 221 of file aligner.h.

References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

                {
                        TypeDict d;
                        d.put("min", EMObject::FLOAT, "Minimum scaling (default: 0.95)");
                        d.put("max", EMObject::FLOAT, "Maximum scaling (default: 1.05)");
                        d.put("step", EMObject::FLOAT, "Scaling step (default: 0.01)");
                        return d;
                }
static Aligner* EMAN::ScaleAligner::NEW ( ) [inline, static]

Definition at line 216 of file aligner.h.

                {
                        return new ScaleAligner();
                }

Member Data Documentation

const string ScaleAligner::NAME = "scale" [static]

Definition at line 230 of file aligner.h.

Referenced by get_name().


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