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

rotational alignment assuming centers are correct More...

#include <aligner.h>

Inheritance diagram for EMAN::RotatePrecenterAligner:
Inheritance graph
[legend]
Collaboration diagram for EMAN::RotatePrecenterAligner:
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 = "rotate_precenter"

Detailed Description

rotational alignment assuming centers are correct

Definition at line 371 of file aligner.h.


Member Function Documentation

EMData * RotatePrecenterAligner::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 496 of file aligner.cpp.

References EMAN::Util::calc_best_fft_size(), EMAN::EMData::calc_ccfx(), data, EMAN::Util::find_max(), EMAN::EMData::get_data(), EMAN::EMData::get_ysize(), ny, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::Transform::set_rotation(), and EMAN::EMData::unwrap().

Referenced by align().

{
        if (!to) {
                return 0;
        }

        int ny = this_img->get_ysize();
        int size = Util::calc_best_fft_size((int) (M_PI * ny * 1.5));
        EMData *e1 = this_img->unwrap(4, ny * 7 / 16, size, 0, 0, 1);
        EMData *e2 = to->unwrap(4, ny * 7 / 16, size, 0, 0, 1);
        EMData *cf = e1->calc_ccfx(e2, 0, ny);

        float *data = cf->get_data();

        float peak = 0;
        int peak_index = 0;
        Util::find_max(data, size, &peak, &peak_index);
        float a = (float) ((1.0f - 1.0f * peak_index / size) * 180. * 2);

        Transform rot;
        rot.set_rotation(Dict("type","2d","alpha",(float)(a*180./M_PI)));
        EMData* rslt = this_img->process("xform",Dict("transform",&rot));
        rslt->set_attr("xform.align2d",&rot);
//
//      Transform* t = get_set_align_attr("xform.align2d",rslt,this_img);
//      t->set_rotation(Dict("type","2d","alpha",-a));
//
//      EMData* result this_img->transform(Dict("type","2d","alpha",(float)(a*180./M_PI)));
//
//      cf->set_attr("xform.align2d",t);
//      delete t;
//      cf->update();

        if( e1 )
        {
                delete e1;
                e1 = 0;
        }

        if( e2 )
        {
                delete e2;
                e2 = 0;
        }

        if (cf) {
                delete cf;
                cf = 0;
        }
        return rslt;
}
virtual EMData* EMAN::RotatePrecenterAligner::align ( EMData this_img,
EMData to_img 
) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 377 of file aligner.h.

References align().

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

Implements EMAN::Aligner.

Definition at line 387 of file aligner.h.

                {
                        return "Performs rotational alignment and works accurately if the image is precentered";
                }
virtual string EMAN::RotatePrecenterAligner::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 382 of file aligner.h.

References NAME.

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

Implements EMAN::Aligner.

Definition at line 397 of file aligner.h.

                {
                        TypeDict d;
                        return d;
                }
static Aligner* EMAN::RotatePrecenterAligner::NEW ( ) [inline, static]

Definition at line 392 of file aligner.h.

                {
                        return new RotatePrecenterAligner();
                }

Member Data Documentation

const string RotatePrecenterAligner::NAME = "rotate_precenter" [static]

Definition at line 403 of file aligner.h.

Referenced by get_name().


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