#include <aligner.h>


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 () |
Definition at line 252 of file aligner.h.
| 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 274 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().
00276 { 00277 if (!to) { 00278 return 0; 00279 } 00280 00281 int ny = this_img->get_ysize(); 00282 int size = Util::calc_best_fft_size((int) (M_PI * ny * 1.5)); 00283 EMData *e1 = this_img->unwrap(4, ny * 7 / 16, size, 0, 0, 1); 00284 EMData *e2 = to->unwrap(4, ny * 7 / 16, size, 0, 0, 1); 00285 EMData *cf = e1->calc_ccfx(e2, 0, ny); 00286 00287 float *data = cf->get_data(); 00288 00289 float peak = 0; 00290 int peak_index = 0; 00291 Util::find_max(data, size, &peak, &peak_index); 00292 float a = (float) ((1.0f - 1.0f * peak_index / size) * 180. * 2); 00293 00294 Transform rot; 00295 rot.set_rotation(Dict("type","2d","alpha",(float)(a*180./M_PI))); 00296 EMData* rslt = this_img->process("math.transform",Dict("transform",&rot)); 00297 rslt->set_attr("xform.align2d",&rot); 00298 // 00299 // Transform* t = get_set_align_attr("xform.align2d",rslt,this_img); 00300 // t->set_rotation(Dict("type","2d","alpha",-a)); 00301 // 00302 // EMData* result this_img->transform(Dict("type","2d","alpha",(float)(a*180./M_PI))); 00303 // 00304 // cf->set_attr("xform.align2d",t); 00305 // delete t; 00306 // cf->update(); 00307 00308 if( e1 ) 00309 { 00310 delete e1; 00311 e1 = 0; 00312 } 00313 00314 if( e2 ) 00315 { 00316 delete e2; 00317 e2 = 0; 00318 } 00319 00320 if (cf) { 00321 delete cf; 00322 cf = 0; 00323 } 00324 00325 return rslt; 00326 }
| virtual EMData* EMAN::RotatePrecenterAligner::align | ( | EMData * | this_img, | |
| EMData * | to_img | |||
| ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 258 of file aligner.h.
References align().
00259 { 00260 return align(this_img, to_img, "", Dict()); 00261 }
| virtual string EMAN::RotatePrecenterAligner::get_name | ( | ) | const [inline, virtual] |
Get the Aligner's name.
Each Aligner is identified by a unique name.
Implements EMAN::Aligner.
Definition at line 263 of file aligner.h.
| virtual string EMAN::RotatePrecenterAligner::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 268 of file aligner.h.
00269 { 00270 return "Performs rotational alignment and works accurately if the image is precentered"; 00271 }
| static Aligner* EMAN::RotatePrecenterAligner::NEW | ( | ) | [inline, static] |
| virtual TypeDict EMAN::RotatePrecenterAligner::get_param_types | ( | ) | const [inline, virtual] |
1.5.6