EMAN::RotateTranslateAlignerPawel Class Reference

Rotational, translational alignment by resampling to polar coordinates. More...

#include <aligner.h>

Inheritance diagram for EMAN::RotateTranslateAlignerPawel:

Inheritance graph
[legend]
Collaboration diagram for EMAN::RotateTranslateAlignerPawel:

Collaboration graph
[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

static AlignerNEW ()

Static Public Attributes

static const string NAME = "rotate_translate_resample"

Detailed Description

Rotational, translational alignment by resampling to polar coordinates.

translation if found by varing to origin using for polar coordinate resampling in real space

Parameters:
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
Author:
John Flanagan
Date:
Feb 8th 2011

Definition at line 630 of file aligner.h.


Member Function Documentation

virtual EMData* EMAN::RotateTranslateAlignerPawel::align ( EMData this_img,
EMData to_img 
) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 636 of file aligner.h.

References align().

00637                 {
00638                         return align(this_img, to_img, "sqeuclidean", Dict());
00639                 }

EMData * RotateTranslateAlignerPawel::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 631 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::Aligner::params, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::Dict::set_default(), EMAN::EMData::unwrap(), x, and y.

Referenced by align().

00633 {
00634         if (cmp_name != "dot" && cmp_name != "ccc") throw InvalidParameterException("Resample aligner only works for dot and ccc");
00635         
00636         int maxtx = params.set_default("tx", 0);
00637         int maxty = params.set_default("ty", 0);
00638         int r1 = params.set_default("r1",-1);
00639         int r2 = params.set_default("r2",-1);
00640         
00641         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");
00642         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");
00643         
00644 //      float best_peak = -numeric_limits<float>::infinity();
00645         float best_peak = -1.0e37;
00646         int best_peak_index = 0;
00647         int best_tx = 0;
00648         int best_ty = 0;
00649         int polarxsize = 0;
00650                 
00651         for(int x = -maxtx; x <= maxtx; x++){
00652                 for(int y = -maxty; y <= maxty; y++){
00653 
00654                         EMData * to_polar = to->unwrap(r1,r2,-1,0,0,true);
00655                         EMData * this_img_polar = this_img->unwrap(r1,r2,-1,x,y,true);
00656                         EMData * cf = this_img_polar->calc_ccfx(to_polar, 0, this_img_polar->get_ysize());
00657                         
00658                         polarxsize = this_img_polar->get_xsize();
00659                         
00660                         //take out the garbage
00661                         delete to_polar; to_polar = 0;
00662                         delete this_img_polar; this_img_polar = 0;
00663         
00664                         float *data = cf->get_data();
00665                         float peak = 0;
00666                         int peak_index = 0;
00667                         Util::find_max(data, polarxsize, &peak, &peak_index);
00668                         delete cf; cf = 0;
00669 
00670                         if(peak > best_peak) {
00671                                 best_peak = peak;
00672                                 best_peak_index = peak_index;
00673                                 best_tx = x;
00674                                 best_ty = y;
00675                         }
00676                 }
00677         }
00678         
00679         float rot_angle = (float) (best_peak_index * 360.0f / polarxsize);
00680                                 
00681         //return the result
00682         Transform tmptt(Dict("type","2d","alpha",0,"tx",-best_tx,"ty",-best_ty));
00683         Transform tmprot(Dict("type","2d","alpha",rot_angle,"tx",0,"ty",0));
00684         Transform total = tmprot*tmptt;
00685         EMData* rotimg=this_img->process("xform",Dict("transform",(Transform*)&total));
00686         rotimg->set_attr("xform.align2d",&total);
00687         
00688         return rotimg;
00689         
00690 }

virtual string EMAN::RotateTranslateAlignerPawel::get_desc (  )  const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 646 of file aligner.h.

00647                 {
00648                         return "Performs rotational alignment and translation align by resampling to polar coordinates in real space.";
00649                 }

virtual string EMAN::RotateTranslateAlignerPawel::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 641 of file aligner.h.

References NAME.

00642                 {
00643                         return NAME;
00644                 }

virtual TypeDict EMAN::RotateTranslateAlignerPawel::get_param_types (  )  const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 656 of file aligner.h.

References EMAN::EMObject::INT, and EMAN::TypeDict::put().

00657                 {
00658                         TypeDict d;
00659                         //d.put("usedot", EMObject::INT);
00660                         d.put("tx", EMObject::INT, "Maximum x translation in pixels, Default = 0");
00661                         d.put("ty", EMObject::INT, "Maximum y translation in pixels, Default = 0");
00662                         d.put("r1", EMObject::INT, "Inner ring, pixels");
00663                         d.put("r2", EMObject::INT, "Outer ring, pixels");
00664                         return d;
00665                 }

static Aligner* EMAN::RotateTranslateAlignerPawel::NEW (  )  [inline, static]

Definition at line 651 of file aligner.h.

00652                 {
00653                         return new RotateTranslateAlignerPawel();
00654                 }


Member Data Documentation

const string RotateTranslateAlignerPawel::NAME = "rotate_translate_resample" [static]

Definition at line 667 of file aligner.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:34:41 2012 for EMAN2 by  doxygen 1.4.7