Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::RotationalAligner Class Reference
[a function or class that is CUDA enabled]

rotational alignment using angular correlation More...

#include <aligner.h>

Inheritance diagram for EMAN::RotationalAligner:

[legend]
Collaboration diagram for EMAN::RotationalAligner:
[legend]
List of all members.

Public Member Functions

virtual EMDataalign (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 EMDataalign (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

AlignerNEW ()
EMDataalign_180_ambiguous (EMData *this_img, EMData *to_img, int rfp_mode=0)

Static Public Attributes

const string NAME = "rotational"

Detailed Description

rotational alignment using angular correlation

Parameters:
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.


Member Function Documentation

virtual EMData* EMAN::RotationalAligner::align EMData this_img,
EMData to_img
const [inline, virtual]
 

Implements EMAN::Aligner.

Definition at line 223 of file aligner.h.

References align().

00224                 {
00225                         return align(this_img, to_img, "", Dict());
00226                 }

EMData * RotationalAligner::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.

Parameters:
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.
Returns:
The aligned image.

Implements EMAN::Aligner.

Definition at line 260 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().

00262 {
00263         if (!to) throw InvalidParameterException("Can not rotational align - the image to align to is NULL");
00264 
00265         // Perform 180 ambiguous alignment
00266         int rfp_mode = params.set_default("rfp_mode",0);
00267         EMData* rot_aligned = RotationalAligner::align_180_ambiguous(this_img,to,rfp_mode);
00268         Transform * tmp = rot_aligned->get_attr("xform.align2d");
00269         Dict rot = tmp->get_rotation("2d");
00270         float rotate_angle_solution = rot["alpha"];
00271         delete tmp;
00272 
00273         EMData *rot_align_180 = rot_aligned->process("math.rotate.180");
00274 
00275         // Generate the comparison metrics for both rotational candidates
00276         float rot_cmp = rot_aligned->cmp(cmp_name, to, cmp_params);
00277         float rot_180_cmp = rot_align_180->cmp(cmp_name, to, cmp_params);
00278         // Decide on the result
00279         float score = 0.0;
00280         EMData* result = NULL;
00281         if (rot_cmp < rot_180_cmp){
00282                 result = rot_aligned;
00283                 score = rot_cmp;
00284                 delete rot_align_180; rot_align_180 = 0;
00285         } else {
00286                 result = rot_align_180;
00287                 score = rot_180_cmp;
00288                 delete rot_aligned; rot_aligned = 0;
00289                 rotate_angle_solution = rotate_angle_solution-180.0f;
00290         }
00291 
00292 //      Transform* t = get_align_attr("xform.align2d",result);
00293 //      t->set_rotation(Dict("type","2d","alpha",rotate_angle_solution));
00294         Transform tmp2(Dict("type","2d","alpha",rotate_angle_solution));
00295         result->set_attr("xform.align2d",&tmp2);
00296         return result;
00297 }

EMData * RotationalAligner::align_180_ambiguous EMData this_img,
EMData to_img,
int  rfp_mode = 0
[static]
 

Definition at line 213 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().

00213                                                                                             {
00214 
00215         // Make translationally invariant rotational footprints
00216         EMData* this_img_rfp, * to_rfp;
00217         if (rfp_mode == 0) {
00218                 this_img_rfp = this_img->make_rotational_footprint_e1();
00219                 to_rfp = to->make_rotational_footprint_e1();
00220         } else if (rfp_mode == 1) {
00221                 this_img_rfp = this_img->make_rotational_footprint();
00222                 to_rfp = to->make_rotational_footprint();
00223         } else if (rfp_mode == 2) {
00224                 this_img_rfp = this_img->make_rotational_footprint_cmc();
00225                 to_rfp = to->make_rotational_footprint_cmc();
00226         } else {
00227                 throw InvalidParameterException("rfp_mode must be 0,1 or 2");
00228         }
00229         int this_img_rfp_nx = this_img_rfp->get_xsize();
00230 
00231         // Do row-wise correlation, returning a sum.
00232         EMData *cf = this_img_rfp->calc_ccfx(to_rfp, 0, this_img->get_ysize());
00233 
00234         // Delete them, they're no longer needed
00235         delete this_img_rfp; this_img_rfp = 0;
00236         delete to_rfp; to_rfp = 0;
00237 
00238         // Now solve the rotational alignment by finding the max in the column sum
00239         float *data = cf->get_data();
00240         float peak = 0;
00241         int peak_index = 0;
00242         Util::find_max(data, this_img_rfp_nx, &peak, &peak_index);
00243 
00244         if( cf ) {
00245                 delete cf;
00246                 cf = 0;
00247         }
00248         float rot_angle = (float) (peak_index * 180.0f / this_img_rfp_nx);
00249 
00250         // Return the result
00251         Transform tmp(Dict("type","2d","alpha",rot_angle));
00252         cf=this_img->process("xform",Dict("transform",(Transform*)&tmp));
00253 //      Transform* t = get_set_align_attr("xform.align2d",cf,this_img);
00254 //      Dict d("type","2d","alpha",rot_angle);
00255 //      t->set_rotation(d);
00256         cf->set_attr("xform.align2d",&tmp);
00257         return cf;
00258 }

virtual string EMAN::RotationalAligner::get_desc  )  const [inline, virtual]
 

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                 }

virtual string EMAN::RotationalAligner::get_name  )  const [inline, virtual]
 

Get the Aligner's name.

Each Aligner is identified by a unique name.

Returns:
The Aligner's name.

Implements EMAN::Aligner.

Definition at line 228 of file aligner.h.

00229                 {
00230                         return NAME;
00231                 }

virtual TypeDict EMAN::RotationalAligner::get_param_types  )  const [inline, virtual]
 

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                 }

Aligner* EMAN::RotationalAligner::NEW  )  [inline, static]
 

Definition at line 238 of file aligner.h.

00239                 {
00240                         return new RotationalAligner();
00241                 }


Member Data Documentation

const string RotationalAligner::NAME = "rotational" [static]
 

Definition at line 54 of file aligner.cpp.


The documentation for this class was generated from the following files:
Generated on Fri Apr 30 15:39:12 2010 for EMAN2 by  doxygen 1.3.9.1