Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

AlignerNEW ()

Static Public Attributes

const string NAME = "rotate_precenter"

Detailed Description

rotational alignment assuming centers are correct

Definition at line 302 of file aligner.h.


Member Function Documentation

virtual EMData* EMAN::RotatePrecenterAligner::align EMData this_img,
EMData to_img
const [inline, virtual]
 

Implements EMAN::Aligner.

Definition at line 308 of file aligner.h.

References align().

00309                 {
00310                         return align(this_img, to_img, "dot", Dict());
00311                 }

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_img The image to be compared.
to_img 'this_img" is aligned with 'to_img'.
cmp_name The comparison method to compare the two images.
cmp_params The parameter dictionary for comparison method.
Returns:
The aligned image.

Implements EMAN::Aligner.

Definition at line 352 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().

00354 {
00355         if (!to) {
00356                 return 0;
00357         }
00358 
00359         int ny = this_img->get_ysize();
00360         int size = Util::calc_best_fft_size((int) (M_PI * ny * 1.5));
00361         EMData *e1 = this_img->unwrap(4, ny * 7 / 16, size, 0, 0, 1);
00362         EMData *e2 = to->unwrap(4, ny * 7 / 16, size, 0, 0, 1);
00363         EMData *cf = e1->calc_ccfx(e2, 0, ny);
00364 
00365         float *data = cf->get_data();
00366 
00367         float peak = 0;
00368         int peak_index = 0;
00369         Util::find_max(data, size, &peak, &peak_index);
00370         float a = (float) ((1.0f - 1.0f * peak_index / size) * 180. * 2);
00371 
00372         Transform rot;
00373         rot.set_rotation(Dict("type","2d","alpha",(float)(a*180./M_PI)));
00374         EMData* rslt = this_img->process("xform",Dict("transform",&rot));
00375         rslt->set_attr("xform.align2d",&rot);
00376 //
00377 //      Transform* t = get_set_align_attr("xform.align2d",rslt,this_img);
00378 //      t->set_rotation(Dict("type","2d","alpha",-a));
00379 //
00380 //      EMData* result this_img->transform(Dict("type","2d","alpha",(float)(a*180./M_PI)));
00381 //
00382 //      cf->set_attr("xform.align2d",t);
00383 //      delete t;
00384 //      cf->update();
00385 
00386         if( e1 )
00387         {
00388                 delete e1;
00389                 e1 = 0;
00390         }
00391 
00392         if( e2 )
00393         {
00394                 delete e2;
00395                 e2 = 0;
00396         }
00397 
00398         if (cf) {
00399                 delete cf;
00400                 cf = 0;
00401         }
00402         return rslt;
00403 }

virtual string EMAN::RotatePrecenterAligner::get_desc  )  const [inline, virtual]
 

Implements EMAN::Aligner.

Definition at line 318 of file aligner.h.

00319                 {
00320                         return "Performs rotational alignment and works accurately if the image is precentered";
00321                 }

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 313 of file aligner.h.

00314                 {
00315                         return NAME;
00316                 }

virtual TypeDict EMAN::RotatePrecenterAligner::get_param_types  )  const [inline, virtual]
 

Implements EMAN::Aligner.

Definition at line 328 of file aligner.h.

00329                 {
00330                         TypeDict d;
00331                         return d;
00332                 }

Aligner* EMAN::RotatePrecenterAligner::NEW  )  [inline, static]
 

Definition at line 323 of file aligner.h.

00324                 {
00325                         return new RotatePrecenterAligner();
00326                 }


Member Data Documentation

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

Definition at line 61 of file aligner.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:51:03 2011 for EMAN2 by  doxygen 1.3.9.1