#include <aligner.h>
Inheritance diagram for EMAN::RotateTranslateAlignerPawel:
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 | |
Aligner * | NEW () |
Static Public Attributes | |
const string | NAME = "rotate_translate_resample" |
translation if found by varing to origin using for polar coordinate resampling in real space
tx | maximum transltion in x direction, must by less than (n/2 - 1 - r2) | |
tu | maximum transltion in y direction, must by less than (n/2 - 1 - r2) | |
r1 | inner ring | |
r2 | outer ring |
Definition at line 634 of file aligner.h.
|
Implements EMAN::Aligner. Definition at line 640 of file aligner.h. References align(). 00641 { 00642 return align(this_img, to_img, "sqeuclidean", Dict()); 00643 }
|
|
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.
Implements EMAN::Aligner. Definition at line 645 of file aligner.cpp. References EMAN::EMData::calc_ccfx(), data, EMAN::Util::find_max(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), InvalidParameterException, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::Dict::set_default(), EMAN::EMData::unwrap(), x, and y. 00647 { 00648 if (cmp_name != "dot" && cmp_name != "ccc") throw InvalidParameterException("Resample aligner only works for dot and ccc"); 00649 00650 int maxtx = params.set_default("tx", 0); 00651 int maxty = params.set_default("ty", 0); 00652 int r1 = params.set_default("r1",-1); 00653 int r2 = params.set_default("r2",-1); 00654 00655 if(this_img->get_xsize()/2 - 1 - r2 - maxtx <= 0 || (r2 == -1 && maxtx > 0)) throw InvalidParameterException("nx/2 - 1 - r2 - tx must be greater than or = 0"); 00656 if(this_img->get_ysize()/2 - 1 - r2 - maxty <= 0 || (r2 == -1 && maxty > 0)) throw InvalidParameterException("ny/2 - 1 - r2 - ty must be greater than or = 0"); 00657 00658 // float best_peak = -numeric_limits<float>::infinity(); 00659 float best_peak = -1.0e37; 00660 int best_peak_index = 0; 00661 int best_tx = 0; 00662 int best_ty = 0; 00663 int polarxsize = 0; 00664 00665 for(int x = -maxtx; x <= maxtx; x++){ 00666 for(int y = -maxty; y <= maxty; y++){ 00667 00668 EMData * to_polar = to->unwrap(r1,r2,-1,0,0,true); 00669 EMData * this_img_polar = this_img->unwrap(r1,r2,-1,x,y,true); 00670 EMData * cf = this_img_polar->calc_ccfx(to_polar, 0, this_img_polar->get_ysize()); 00671 00672 polarxsize = this_img_polar->get_xsize(); 00673 00674 //take out the garbage 00675 delete to_polar; to_polar = 0; 00676 delete this_img_polar; this_img_polar = 0; 00677 00678 float *data = cf->get_data(); 00679 float peak = 0; 00680 int peak_index = 0; 00681 Util::find_max(data, polarxsize, &peak, &peak_index); 00682 delete cf; cf = 0; 00683 00684 if(peak > best_peak) { 00685 best_peak = peak; 00686 best_peak_index = peak_index; 00687 best_tx = x; 00688 best_ty = y; 00689 } 00690 } 00691 } 00692 00693 float rot_angle = (float) (best_peak_index * 360.0f / polarxsize); 00694 00695 //return the result 00696 Transform tmptt(Dict("type","2d","alpha",0,"tx",-best_tx,"ty",-best_ty)); 00697 Transform tmprot(Dict("type","2d","alpha",rot_angle,"tx",0,"ty",0)); 00698 Transform total = tmprot*tmptt; 00699 EMData* rotimg=this_img->process("xform",Dict("transform",(Transform*)&total)); 00700 rotimg->set_attr("xform.align2d",&total); 00701 00702 return rotimg; 00703 00704 }
|
|
Implements EMAN::Aligner. Definition at line 650 of file aligner.h. 00651 { 00652 return "Performs rotational alignment and translation align by resampling to polar coordinates in real space."; 00653 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 645 of file aligner.h. 00646 {
00647 return NAME;
00648 }
|
|
Implements EMAN::Aligner. Definition at line 660 of file aligner.h. References EMAN::TypeDict::put(). 00661 { 00662 TypeDict d; 00663 //d.put("usedot", EMObject::INT); 00664 d.put("tx", EMObject::INT, "Maximum x translation in pixels, Default = 0"); 00665 d.put("ty", EMObject::INT, "Maximum y translation in pixels, Default = 0"); 00666 d.put("r1", EMObject::INT, "Inner ring, pixels"); 00667 d.put("r2", EMObject::INT, "Outer ring, pixels"); 00668 return d; 00669 }
|
|
Definition at line 655 of file aligner.h. 00656 { 00657 return new RotateTranslateAlignerPawel(); 00658 }
|
|
Definition at line 67 of file aligner.cpp. |