core/vgl/algo/vgl_norm_trans_2d.h
Go to the documentation of this file.
00001 // This is core/vgl/algo/vgl_norm_trans_2d.h
00002 #ifndef vgl_norm_trans_2d_h_
00003 #define vgl_norm_trans_2d_h_
00004 //:
00005 // \file
00006 // \brief The similarity transform that normalizes a point set
00007 //
00008 // Algorithms to compute projective transformations require that
00009 // the data be conditioned by insuring that the center of gravity
00010 // of the point (line) set is at the origin and the standard deviation
00011 // is isotropic and unity.
00012 //
00013 // The isotropic flag determines if a principal axis computation is
00014 // done to anisotropically scale the points along the principal axes.
00015 // If isotropic == true then points are scaled so that the average
00016 // point radius with respect to the center of mass is unity.
00017 // If isotropic = false then the points are rotated and radii scaled
00018 // according to the standard deviations along the principal axes.
00019 //
00020 // \verbatim
00021 //  Modifications
00022 //   Created March 24, 2003 - J.L. Mundy
00023 //   May 15, 2003 - Added normalization computation for lines based on
00024 //                  the point set defined by the intersection of each line
00025 //                  with the perpendicular line from the origin.
00026 //   Jun 23, 2003 - Peter Vanroose - added compute_from_points_and_lines()
00027 //   Jun 17, 2005 - J.L. Mundy - added anisotropic scaling
00028 //   Sep 27, 2007 - Ricardo Fabbri - isotropic scaling set to sqrt(2) factor
00029 // \endverbatim
00030 
00031 #include <vnl/vnl_matrix_fixed.h>
00032 #include <vgl/vgl_homg_point_2d.h>
00033 #include <vgl/vgl_homg_line_2d.h>
00034 #include <vcl_iosfwd.h>
00035 #include <vgl/algo/vgl_h_matrix_2d.h>
00036 
00037 template <class T>
00038 class vgl_norm_trans_2d: public vgl_h_matrix_2d<T>
00039 {
00040  public:
00041 
00042   // Constructors/Initializers/Destructors-------------------------------------
00043 
00044   vgl_norm_trans_2d();
00045   vgl_norm_trans_2d(const vgl_norm_trans_2d<T>& M);
00046   vgl_norm_trans_2d(vnl_matrix_fixed<T,3,3> const& M);
00047   vgl_norm_trans_2d(const T* t_matrix);
00048   vgl_norm_trans_2d(vcl_istream& s);
00049   vgl_norm_trans_2d(char const* filename);
00050  ~vgl_norm_trans_2d();
00051 
00052   // Operations----------------------------------------------------------------
00053 
00054   //: compute the normalizing transform
00055   bool compute_from_points(vcl_vector<vgl_homg_point_2d<T> > const& points,
00056                            bool isotropic = true);
00057   bool compute_from_lines(vcl_vector<vgl_homg_line_2d<T>  > const& lines,
00058                           bool isotropic = true);
00059   bool
00060     compute_from_points_and_lines(vcl_vector<vgl_homg_point_2d<T> > const& pts,
00061                                   vcl_vector<vgl_homg_line_2d<T> > const& lines
00062                                   , bool isotropic = true);
00063 
00064  protected :
00065   //Utility functions
00066 
00067   static bool scale_xyroot2(vcl_vector<vgl_homg_point_2d<T> > const& in,
00068                             T& radius);
00069 
00070   static void center_of_mass(vcl_vector<vgl_homg_point_2d<T> > const& points,
00071                              T& cx, T& cy);
00072 
00073   static bool scale_aniostropic(vcl_vector<vgl_homg_point_2d<T> > const& in,
00074                                 T& sdx, T& sdy, T& c, T& s);
00075 };
00076 
00077 #define VGL_NORM_TRANS_2D_INSTANTIATE(T) extern "please include vgl/algo/vgl_norm_trans_2d.txx first"
00078 
00079 #endif // vgl_norm_trans_2d_h_