#include <aligner.h>
Inheritance diagram for EMAN::RotateTranslateFlipAlignerPawel:
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_flip_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 726 of file aligner.h.
|
Implements EMAN::Aligner. Definition at line 732 of file aligner.h. References align(). 00733 { 00734 return align(this_img, to_img, "sqeuclidean", Dict()); 00735 }
|
|
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 724 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::process_inplace(), EMAN::EMData::set_attr(), EMAN::Dict::set_default(), EMAN::EMData::unwrap(), x, and y. 00726 { 00727 if (cmp_name != "dot" && cmp_name != "ccc") throw InvalidParameterException("Resample aligner only works for dot and ccc"); 00728 00729 int maxtx = params.set_default("tx", 0); 00730 int maxty = params.set_default("ty", 0); 00731 int r1 = params.set_default("r1",-1); 00732 int r2 = params.set_default("r2",-1); 00733 00734 if(this_img->get_xsize()/2 - 1 - r2 - maxtx <= 0 || (r2 == -1 && maxtx > 0)){ 00735 cout << "\nRunTimeError: nx/2 - 1 - r2 - tx must be greater than or = 0\n" << endl; // For some reason the expection message is not being print, stupid C++ 00736 throw InvalidParameterException("nx/2 - 1 - r2 - tx must be greater than or = 0"); 00737 } 00738 if(this_img->get_ysize()/2 - 1 - r2 - maxty <= 0 || (r2 == -1 && maxty > 0)){ 00739 cout << "\nRunTimeError:ny/2 - 1 - r2 - ty must be greater than or = 0\n" << endl; // For some reason the expection message is not being print, stupid C++ 00740 throw InvalidParameterException("ny/2 - 1 - r2 - ty must be greater than or = 0"); 00741 } 00742 00743 float best_peak = -numeric_limits<float>::infinity(); 00744 int best_peak_index = 0; 00745 int best_tx = 0; 00746 int best_ty = 0; 00747 int polarxsize = 0; 00748 bool flip = false; 00749 00750 for(int x = -maxtx; x <= maxtx; x++){ 00751 for(int y = -maxty; y <= maxty; y++){ 00752 00753 EMData * to_polar = to->unwrap(r1,r2,-1,0,0,true); 00754 EMData * this_img_polar = this_img->unwrap(r1,r2,-1,x,y,true); 00755 EMData * cfflip = this_img_polar->calc_ccfx(to_polar, 0, this_img_polar->get_ysize(), false, true); 00756 EMData * cf = this_img_polar->calc_ccfx(to_polar, 0, this_img_polar->get_ysize()); 00757 00758 polarxsize = this_img_polar->get_xsize(); 00759 00760 //take out the garbage 00761 delete to_polar; to_polar = 0; 00762 delete this_img_polar; this_img_polar = 0; 00763 00764 float *data = cf->get_data(); 00765 float peak = 0; 00766 int peak_index = 0; 00767 Util::find_max(data, polarxsize, &peak, &peak_index); 00768 delete cf; cf = 0; 00769 00770 if(peak > best_peak) { 00771 best_peak = peak; 00772 best_peak_index = peak_index; 00773 best_tx = x; 00774 best_ty = y; 00775 flip = false; 00776 } 00777 00778 data = cfflip->get_data(); 00779 Util::find_max(data, polarxsize, &peak, &peak_index); 00780 delete cfflip; cfflip = 0; 00781 00782 if(peak > best_peak) { 00783 best_peak = peak; 00784 best_peak_index = peak_index; 00785 best_tx = x; 00786 best_ty = y; 00787 flip = true; 00788 } 00789 } 00790 } 00791 00792 float rot_angle = (float) (best_peak_index * 360.0f / polarxsize); 00793 00794 //return the result 00795 Transform tmptt(Dict("type","2d","alpha",0,"tx",-best_tx,"ty",-best_ty)); 00796 Transform tmprot(Dict("type","2d","alpha",rot_angle,"tx",0,"ty",0)); 00797 Transform total = tmprot*tmptt; 00798 EMData* rotimg=this_img->process("xform",Dict("transform",(Transform*)&total)); 00799 rotimg->set_attr("xform.align2d",&total); 00800 if(flip == true) { 00801 rotimg->process_inplace("xform.flip",Dict("axis", "x")); 00802 } 00803 00804 return rotimg; 00805 00806 }
|
|
Implements EMAN::Aligner. Definition at line 742 of file aligner.h. 00743 { 00744 return "Performs rotational alignment, translation align, and flip by resampling to polar coordinates in real space."; 00745 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 737 of file aligner.h. 00738 {
00739 return NAME;
00740 }
|
|
Implements EMAN::Aligner. Definition at line 752 of file aligner.h. References EMAN::TypeDict::put(). 00753 { 00754 TypeDict d; 00755 //d.put("usedot", EMObject::INT); 00756 d.put("tx", EMObject::INT, "Maximum x translation in pixels, Default = 0"); 00757 d.put("ty", EMObject::INT, "Maximum y translation in pixels, Default = 0"); 00758 d.put("r1", EMObject::INT, "Inner ring, pixels"); 00759 d.put("r2", EMObject::INT, "Outer ring, pixels"); 00760 return d; 00761 }
|
|
Definition at line 747 of file aligner.h. 00748 { 00749 return new RotateTranslateFlipAlignerPawel(); 00750 }
|
|
Definition at line 70 of file aligner.cpp. |