vgl_norm_trans_2d.h
Go to the documentation of this file.
1 // This is core/vgl/algo/vgl_norm_trans_2d.h
2 #ifndef vgl_norm_trans_2d_h_
3 #define vgl_norm_trans_2d_h_
4 //:
5 // \file
6 // \brief The similarity transform that normalizes a point set
7 //
8 // Algorithms to compute projective transformations require that
9 // the data be conditioned by insuring that the center of gravity
10 // of the point (line) set is at the origin and the standard deviation
11 // is isotropic and unity.
12 //
13 // The isotropic flag determines if a principal axis computation is
14 // done to anisotropically scale the points along the principal axes.
15 // If isotropic == true then points are scaled so that the average
16 // point radius with respect to the center of mass is unity.
17 // If isotropic = false then the points are rotated and radii scaled
18 // according to the standard deviations along the principal axes.
19 //
20 // \verbatim
21 // Modifications
22 // Created March 24, 2003 - J.L. Mundy
23 // May 15, 2003 - Added normalization computation for lines based on
24 // the point set defined by the intersection of each line
25 // with the perpendicular line from the origin.
26 // Jun 23, 2003 - Peter Vanroose - added compute_from_points_and_lines()
27 // Jun 17, 2005 - J.L. Mundy - added anisotropic scaling
28 // Sep 27, 2007 - Ricardo Fabbri - isotropic scaling set to sqrt(2) factor
29 // \endverbatim
30 
31 #include <iosfwd>
32 #include <vnl/vnl_matrix_fixed.h>
33 #include <vgl/vgl_homg_point_2d.h>
34 #include <vgl/vgl_homg_line_2d.h>
35 #ifdef _MSC_VER
36 # include <vcl_msvc_warnings.h>
37 #endif
39 
40 template <class T>
41 class vgl_norm_trans_2d: public vgl_h_matrix_2d<T>
42 {
43  public:
44 
45  // Constructors/Initializers/Destructors-------------------------------------
46 
49  vgl_norm_trans_2d(vnl_matrix_fixed<T,3,3> const& M);
50  vgl_norm_trans_2d(const T* t_matrix);
51  vgl_norm_trans_2d(std::istream& s);
52  vgl_norm_trans_2d(char const* filename);
54 
55  // Operations----------------------------------------------------------------
56 
57  //: compute the normalizing transform
58  bool compute_from_points(std::vector<vgl_homg_point_2d<T> > const& points,
59  bool isotropic = true);
60  bool compute_from_lines(std::vector<vgl_homg_line_2d<T> > const& lines,
61  bool isotropic = true);
62  bool
63  compute_from_points_and_lines(std::vector<vgl_homg_point_2d<T> > const& pts,
64  std::vector<vgl_homg_line_2d<T> > const& lines
65  , bool isotropic = true);
66 
67  protected :
68  //Utility functions
69 
70  static bool scale_xyroot2(std::vector<vgl_homg_point_2d<T> > const& in,
71  T& radius);
72 
73  static void center_of_mass(std::vector<vgl_homg_point_2d<T> > const& points,
74  T& cx, T& cy);
75 
76  static bool scale_aniostropic(std::vector<vgl_homg_point_2d<T> > const& in,
77  T& sdx, T& sdy, T& c, T& s);
78 };
79 
80 #define VGL_NORM_TRANS_2D_INSTANTIATE(T) extern "please include vgl/algo/vgl_norm_trans_2d.hxx first"
81 
82 #endif // vgl_norm_trans_2d_h_
A class to hold a plane-to-plane projective transformation matrix and to perform common operations us...
Definition: vgl_algo_fwd.h:11
Represents a homogeneous 2D line.
Definition: vgl_fwd.h:14
3x3 plane-to-plane projectivity
static bool scale_aniostropic(std::vector< vgl_homg_point_2d< T > > const &in, T &sdx, T &sdy, T &c, T &s)
line in projective 2D space
static void center_of_mass(std::vector< vgl_homg_point_2d< T > > const &points, T &cx, T &cy)
bool compute_from_lines(std::vector< vgl_homg_line_2d< T > > const &lines, bool isotropic=true)
The normalizing transform for lines is computed from the set of points defined by the intersection of...
point in projective 2D space
bool compute_from_points_and_lines(std::vector< vgl_homg_point_2d< T > > const &pts, std::vector< vgl_homg_line_2d< T > > const &lines, bool isotropic=true)
The normalizing transform for points and lines is computed from the set of points used by compute_fro...
bool compute_from_points(std::vector< vgl_homg_point_2d< T > > const &points, bool isotropic=true)
compute the normalizing transform.
Represents a homogeneous 2D point.
Definition: vgl_fwd.h:8
static bool scale_xyroot2(std::vector< vgl_homg_point_2d< T > > const &in, T &radius)