#include <aligner.h>
Inheritance diagram for EMAN::RotatePrecenterAligner:
Public Member Functions | |
virtual EMData * | align (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 EMData * | align (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 Aligner * | NEW () |
Static Public Attributes | |
static const string | NAME = "rotate_precenter" |
Definition at line 371 of file aligner.h.
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().
00378 { 00379 return align(this_img, to_img, "dot", Dict()); 00380 }
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.
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. |
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().
00498 { 00499 if (!to) { 00500 return 0; 00501 } 00502 00503 int ny = this_img->get_ysize(); 00504 int size = Util::calc_best_fft_size((int) (M_PI * ny * 1.5)); 00505 EMData *e1 = this_img->unwrap(4, ny * 7 / 16, size, 0, 0, 1); 00506 EMData *e2 = to->unwrap(4, ny * 7 / 16, size, 0, 0, 1); 00507 EMData *cf = e1->calc_ccfx(e2, 0, ny); 00508 00509 float *data = cf->get_data(); 00510 00511 float peak = 0; 00512 int peak_index = 0; 00513 Util::find_max(data, size, &peak, &peak_index); 00514 float a = (float) ((1.0f - 1.0f * peak_index / size) * 180. * 2); 00515 00516 Transform rot; 00517 rot.set_rotation(Dict("type","2d","alpha",(float)(a*180./M_PI))); 00518 EMData* rslt = this_img->process("xform",Dict("transform",&rot)); 00519 rslt->set_attr("xform.align2d",&rot); 00520 // 00521 // Transform* t = get_set_align_attr("xform.align2d",rslt,this_img); 00522 // t->set_rotation(Dict("type","2d","alpha",-a)); 00523 // 00524 // EMData* result this_img->transform(Dict("type","2d","alpha",(float)(a*180./M_PI))); 00525 // 00526 // cf->set_attr("xform.align2d",t); 00527 // delete t; 00528 // cf->update(); 00529 00530 if( e1 ) 00531 { 00532 delete e1; 00533 e1 = 0; 00534 } 00535 00536 if( e2 ) 00537 { 00538 delete e2; 00539 e2 = 0; 00540 } 00541 00542 if (cf) { 00543 delete cf; 00544 cf = 0; 00545 } 00546 return rslt; 00547 }
virtual string EMAN::RotatePrecenterAligner::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 387 of file aligner.h.
00388 { 00389 return "Performs rotational alignment and works accurately if the image is precentered"; 00390 }
virtual string EMAN::RotatePrecenterAligner::get_name | ( | ) | const [inline, virtual] |
virtual TypeDict EMAN::RotatePrecenterAligner::get_param_types | ( | ) | const [inline, virtual] |
static Aligner* EMAN::RotatePrecenterAligner::NEW | ( | ) | [inline, static] |
const string RotatePrecenterAligner::NAME = "rotate_precenter" [static] |