#include <aligner.h>
Inheritance diagram for EMAN::RotationalAligner:
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 () |
EMData * | align_180_ambiguous (EMData *this_img, EMData *to_img, int rfp_mode=0) |
Static Public Attributes | |
const string | NAME = "rotational" |
rfp_mode | Either 0,1 or 2. A temporary flag for testing the rotational foot print. O is the original eman1 way. 1 is just using calc_ccf without padding. 2 is using calc_mutual_correlation without padding |
Definition at line 217 of file aligner.h.
|
Implements EMAN::Aligner. Definition at line 223 of file aligner.h. References align(). 00224 { 00225 return align(this_img, to_img, "dot", Dict()); 00226 }
|
|
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 265 of file aligner.cpp. References align_180_ambiguous(), EMAN::EMData::cmp(), EMAN::EMData::get_attr(), EMAN::Transform::get_rotation(), InvalidParameterException, EMAN::EMData::process(), EMAN::EMData::set_attr(), and EMAN::Dict::set_default(). 00267 { 00268 if (!to) throw InvalidParameterException("Can not rotational align - the image to align to is NULL"); 00269 00270 // Perform 180 ambiguous alignment 00271 int rfp_mode = params.set_default("rfp_mode",0); 00272 EMData* rot_aligned = RotationalAligner::align_180_ambiguous(this_img,to,rfp_mode); 00273 Transform * tmp = rot_aligned->get_attr("xform.align2d"); 00274 Dict rot = tmp->get_rotation("2d"); 00275 float rotate_angle_solution = rot["alpha"]; 00276 delete tmp; 00277 00278 EMData *rot_align_180 = rot_aligned->process("math.rotate.180"); 00279 00280 // Generate the comparison metrics for both rotational candidates 00281 float rot_cmp = rot_aligned->cmp(cmp_name, to, cmp_params); 00282 float rot_180_cmp = rot_align_180->cmp(cmp_name, to, cmp_params); 00283 00284 // Decide on the result 00285 float score = 0.0; 00286 EMData* result = NULL; 00287 if (rot_cmp < rot_180_cmp){ 00288 result = rot_aligned; 00289 score = rot_cmp; 00290 delete rot_align_180; rot_align_180 = 0; 00291 } else { 00292 result = rot_align_180; 00293 score = rot_180_cmp; 00294 delete rot_aligned; rot_aligned = 0; 00295 rotate_angle_solution = rotate_angle_solution-180.0f; 00296 } 00297 00298 // Transform* t = get_align_attr("xform.align2d",result); 00299 // t->set_rotation(Dict("type","2d","alpha",rotate_angle_solution)); 00300 Transform tmp2(Dict("type","2d","alpha",rotate_angle_solution)); 00301 result->set_attr("xform.align2d",&tmp2); 00302 return result; 00303 }
|
|
Definition at line 218 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::make_rotational_footprint(), EMAN::EMData::make_rotational_footprint_cmc(), EMAN::EMData::make_rotational_footprint_e1(), EMAN::EMData::process(), and EMAN::EMData::set_attr(). Referenced by EMAN::RotateTranslateAligner::align(), and align(). 00218 { 00219 00220 // Make translationally invariant rotational footprints 00221 EMData* this_img_rfp, * to_rfp; 00222 if (rfp_mode == 0) { 00223 this_img_rfp = this_img->make_rotational_footprint_e1(); 00224 to_rfp = to->make_rotational_footprint_e1(); 00225 } else if (rfp_mode == 1) { 00226 this_img_rfp = this_img->make_rotational_footprint(); 00227 to_rfp = to->make_rotational_footprint(); 00228 } else if (rfp_mode == 2) { 00229 this_img_rfp = this_img->make_rotational_footprint_cmc(); 00230 to_rfp = to->make_rotational_footprint_cmc(); 00231 } else { 00232 throw InvalidParameterException("rfp_mode must be 0,1 or 2"); 00233 } 00234 int this_img_rfp_nx = this_img_rfp->get_xsize(); 00235 00236 // Do row-wise correlation, returning a sum. 00237 EMData *cf = this_img_rfp->calc_ccfx(to_rfp, 0, this_img->get_ysize()); 00238 00239 // Delete them, they're no longer needed 00240 delete this_img_rfp; this_img_rfp = 0; 00241 delete to_rfp; to_rfp = 0; 00242 00243 // Now solve the rotational alignment by finding the max in the column sum 00244 float *data = cf->get_data(); 00245 float peak = 0; 00246 int peak_index = 0; 00247 Util::find_max(data, this_img_rfp_nx, &peak, &peak_index); 00248 00249 if( cf ) { 00250 delete cf; 00251 cf = 0; 00252 } 00253 float rot_angle = (float) (peak_index * 180.0f / this_img_rfp_nx); 00254 00255 // Return the result 00256 Transform tmp(Dict("type","2d","alpha",rot_angle)); 00257 cf=this_img->process("xform",Dict("transform",(Transform*)&tmp)); 00258 // Transform* t = get_set_align_attr("xform.align2d",cf,this_img); 00259 // Dict d("type","2d","alpha",rot_angle); 00260 // t->set_rotation(d); 00261 cf->set_attr("xform.align2d",&tmp); 00262 return cf; 00263 }
|
|
Implements EMAN::Aligner. Definition at line 233 of file aligner.h. 00234 { 00235 return "Performs rotational alignment,works accurately if the image is precentered, normally called internally in combination with translational and flip alignment"; 00236 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 228 of file aligner.h. 00229 {
00230 return NAME;
00231 }
|
|
Implements EMAN::Aligner. Definition at line 245 of file aligner.h. References EMAN::TypeDict::put(). 00246 { 00247 TypeDict d; 00248 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print. O is the original eman1 way. 1 is just using calc_ccf without padding. 2 is using calc_mutual_correlation without padding."); 00249 return d; 00250 }
|
|
Definition at line 238 of file aligner.h. 00239 { 00240 return new RotationalAligner(); 00241 }
|
|
Definition at line 54 of file aligner.cpp. |