Public Member Functions | Protected Attributes | List of all members
vgl_h_matrix_2d< T > Class Template Reference

A class to hold a plane-to-plane projective transformation matrix and to perform common operations using it e.g. More...

#include <vgl_algo_fwd.h>

Inheritance diagram for vgl_h_matrix_2d< T >:
Inheritance graph
[legend]

Public Member Functions

 vgl_h_matrix_2d ()=default
 
 ~vgl_h_matrix_2d ()=default
 
 vgl_h_matrix_2d (vgl_h_matrix_2d< T > const &M)
 Copy constructor. More...
 
 vgl_h_matrix_2d (vnl_matrix_fixed< T, 3, 3 > const &M)
 Constructor from a 3x3 matrix, and implicit cast from vnl_matrix_fixed<T,3,3>. More...
 
 vgl_h_matrix_2d (vnl_matrix_fixed< T, 2, 2 > const &M, vnl_vector_fixed< T, 2 > const &m)
 Construct an affine vgl_h_matrix_2d from 2x2 M and 2x1 m. More...
 
 vgl_h_matrix_2d (T const *M)
 Constructor from 3x3 C-array. More...
 
 vgl_h_matrix_2d (std::istream &s)
 Constructor from istream. More...
 
 vgl_h_matrix_2d (char const *filename)
 Constructor from file. More...
 
 vgl_h_matrix_2d (std::vector< vgl_homg_point_2d< T > > const &points1, std::vector< vgl_homg_point_2d< T > > const &points2)
 Constructor - calculate homography between two sets of 2D points (minimum 4). More...
 
vgl_homg_point_2d< T > operator() (vgl_homg_point_2d< T > const &p) const
 Return the transformed point given by $q = {\tt H} p$. More...
 
vgl_homg_point_2d< T > operator * (vgl_homg_point_2d< T > const &p) const
 Return the transformed point given by $q = {\tt H} p$. More...
 
bool operator== (vgl_h_matrix_2d< T > const &M) const
 
vgl_homg_line_2d< T > preimage (vgl_homg_line_2d< T > const &l) const
 Return the transformed line given by $m = {\tt H} l$. More...
 
vgl_homg_line_2d< T > correlation (vgl_homg_point_2d< T > const &p) const
 
vgl_homg_point_2d< T > correlation (vgl_homg_line_2d< T > const &l) const
 
vgl_conic< T > operator() (vgl_conic< T > const &C) const
 assumed to be a point conic. More...
 
vgl_homg_point_2d< T > preimage (vgl_homg_point_2d< T > const &q) const
 Return the transformed point given by $p = {\tt H}^{-1} q$. More...
 
vgl_homg_line_2d< T > operator() (vgl_homg_line_2d< T > const &l) const
 Return the transformed line given by $m = {\tt H}^{-1} l$. More...
 
vgl_homg_line_2d< T > operator * (vgl_homg_line_2d< T > const &l) const
 Return the transformed line given by $m = {\tt H}^{-1} l$. More...
 
vgl_conic< T > preimage (vgl_conic< T > const &C) const
 assumed to be a point conic. More...
 
vgl_h_matrix_2d< T > operator * (vgl_h_matrix_2d< T > const &H) const
 composition (*this) * H. More...
 
vnl_matrix_fixed< T, 3, 3 > const & get_matrix () const
 Return the 3x3 homography matrix. More...
 
void get (vnl_matrix_fixed< T, 3, 3 > *M) const
 Fill M with contents of the 3x3 homography matrix. More...
 
void get (vnl_matrix< T > *M) const
 
void get (T *M) const
 Fill M with contents of the 3x3 homography matrix. More...
 
get (unsigned int row_index, unsigned int col_index) const
 Return an element from the 3x3 homography matrix. More...
 
vgl_h_matrix_2d get_inverse () const
 Return the inverse homography. More...
 
vgl_h_matrix_2dset (unsigned int row_index, unsigned int col_index, T value)
 Set an element of the 3x3 homography matrix. More...
 
vgl_h_matrix_2dset (T const *M)
 Set to 3x3 row-stored matrix. More...
 
vgl_h_matrix_2dset (vnl_matrix_fixed< T, 3, 3 > const &M)
 Set to given 3x3 matrix. More...
 
vgl_h_matrix_2dset_identity ()
 initialize the transformation to identity. More...
 
vgl_h_matrix_2dset_translation (T tx, T ty)
 set H[0][2] = tx and H[1][2] = ty, other elements unaltered. More...
 
vgl_h_matrix_2dset_rotation (T theta)
 the upper 2x2 part of the matrix is replaced by a rotation matrix. More...
 
vgl_h_matrix_2dset_scale (T scale)
 compose the current transform with a uniform scaling transformation, S. More...
 
vgl_h_matrix_2dset_similarity (T s, T theta, T tx, T ty)
 set the transform to a similarity mapping. More...
 
vgl_h_matrix_2dset_aspect_ratio (T aspect_ratio)
 compose the transform with diagonal aspect ratio transform. More...
 
vgl_h_matrix_2dset_affine (vnl_matrix_fixed< T, 2, 3 > const &M23)
 set the transform to a general affine transform matrix. More...
 
vgl_h_matrix_2dset_affine (vnl_matrix< T > const &M23)
 
bool is_rotation () const
 
bool is_euclidean () const
 
bool is_identity () const
 
bool projective_basis (std::vector< vgl_homg_point_2d< T > > const &four_points)
 transformation to projective basis (canonical frame). More...
 
bool projective_basis (std::vector< vgl_homg_line_2d< T > > const &four_lines)
 transformation to projective basis (canonical frame). More...
 
vgl_h_matrix_2d< T > get_upper_2x2 () const
 corresponds to rotation for Euclidean transformations. More...
 
vnl_matrix_fixed< T, 2, 2 > get_upper_2x2_matrix () const
 corresponds to rotation for Euclidean transformations. More...
 
vgl_homg_point_2d< T > get_translation () const
 corresponds to translation for affine transformations. More...
 
vnl_vector_fixed< T, 2 > get_translation_vector () const
 corresponds to translation for affine transformations. More...
 
bool read (std::istream &s)
 Read H from std::istream. More...
 
bool read (char const *filename)
 Read H from file. More...
 

Protected Attributes

vnl_matrix_fixed< T, 3, 3 > t12_matrix_
 

Detailed Description

template<class T>
class vgl_h_matrix_2d< T >

A class to hold a plane-to-plane projective transformation matrix and to perform common operations using it e.g.

transfer point.

Definition at line 11 of file vgl_algo_fwd.h.

Constructor & Destructor Documentation

◆ vgl_h_matrix_2d() [1/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( )
default

◆ ~vgl_h_matrix_2d()

template<class T>
vgl_h_matrix_2d< T >::~vgl_h_matrix_2d ( )
default

◆ vgl_h_matrix_2d() [2/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( vgl_h_matrix_2d< T > const &  M)
inline

Copy constructor.

Definition at line 51 of file vgl_h_matrix_2d.h.

◆ vgl_h_matrix_2d() [3/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( vnl_matrix_fixed< T, 3, 3 > const &  M)
inline

Constructor from a 3x3 matrix, and implicit cast from vnl_matrix_fixed<T,3,3>.

Definition at line 53 of file vgl_h_matrix_2d.h.

◆ vgl_h_matrix_2d() [4/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( vnl_matrix_fixed< T, 2, 2 > const &  M,
vnl_vector_fixed< T, 2 > const &  m 
)

Construct an affine vgl_h_matrix_2d from 2x2 M and 2x1 m.

Definition at line 70 of file vgl_h_matrix_2d.hxx.

◆ vgl_h_matrix_2d() [5/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( T const *  M)
inlineexplicit

Constructor from 3x3 C-array.

Definition at line 58 of file vgl_h_matrix_2d.h.

◆ vgl_h_matrix_2d() [6/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( std::istream &  s)
explicit

Constructor from istream.

Definition at line 21 of file vgl_h_matrix_2d.hxx.

◆ vgl_h_matrix_2d() [7/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( char const *  filename)
explicit

Constructor from file.

Definition at line 27 of file vgl_h_matrix_2d.hxx.

◆ vgl_h_matrix_2d() [8/8]

template<class T>
vgl_h_matrix_2d< T >::vgl_h_matrix_2d ( std::vector< vgl_homg_point_2d< T > > const &  points1,
std::vector< vgl_homg_point_2d< T > > const &  points2 
)

Constructor - calculate homography between two sets of 2D points (minimum 4).

Definition at line 37 of file vgl_h_matrix_2d.hxx.

Member Function Documentation

◆ correlation() [1/2]

template<class T>
vgl_homg_line_2d< T > vgl_h_matrix_2d< T >::correlation ( vgl_homg_point_2d< T > const &  p) const

Definition at line 96 of file vgl_h_matrix_2d.hxx.

◆ correlation() [2/2]

template<class T>
vgl_homg_point_2d< T > vgl_h_matrix_2d< T >::correlation ( vgl_homg_line_2d< T > const &  l) const

Definition at line 112 of file vgl_h_matrix_2d.hxx.

◆ get() [1/4]

template<class T>
void vgl_h_matrix_2d< T >::get ( vnl_matrix_fixed< T, 3, 3 > *  M) const

Fill M with contents of the 3x3 homography matrix.

Definition at line 201 of file vgl_h_matrix_2d.hxx.

◆ get() [2/4]

template<class T>
void vgl_h_matrix_2d< T >::get ( vnl_matrix< T > *  M) const
Deprecated:
use the vnl_matrix_fixed variant instead

Definition at line 207 of file vgl_h_matrix_2d.hxx.

◆ get() [3/4]

template<class T>
void vgl_h_matrix_2d< T >::get ( T *  M) const

Fill M with contents of the 3x3 homography matrix.

Definition at line 194 of file vgl_h_matrix_2d.hxx.

◆ get() [4/4]

template<class T>
T vgl_h_matrix_2d< T >::get ( unsigned int  row_index,
unsigned int  col_index 
) const

Return an element from the 3x3 homography matrix.

Definition at line 188 of file vgl_h_matrix_2d.hxx.

◆ get_inverse()

template<class T >
vgl_h_matrix_2d< T > vgl_h_matrix_2d< T >::get_inverse ( ) const

Return the inverse homography.

Definition at line 377 of file vgl_h_matrix_2d.hxx.

◆ get_matrix()

template<class T>
vnl_matrix_fixed<T,3,3> const& vgl_h_matrix_2d< T >::get_matrix ( ) const
inline

Return the 3x3 homography matrix.

Definition at line 102 of file vgl_h_matrix_2d.h.

◆ get_translation()

template<class T >
vgl_homg_point_2d< T > vgl_h_matrix_2d< T >::get_translation ( ) const

corresponds to translation for affine transformations.

Definition at line 488 of file vgl_h_matrix_2d.hxx.

◆ get_translation_vector()

template<class T >
vnl_vector_fixed< T, 2 > vgl_h_matrix_2d< T >::get_translation_vector ( ) const

corresponds to translation for affine transformations.

Definition at line 500 of file vgl_h_matrix_2d.hxx.

◆ get_upper_2x2()

template<class T >
vgl_h_matrix_2d< T > vgl_h_matrix_2d< T >::get_upper_2x2 ( ) const

corresponds to rotation for Euclidean transformations.

Definition at line 461 of file vgl_h_matrix_2d.hxx.

◆ get_upper_2x2_matrix()

template<class T >
vnl_matrix_fixed< T, 2, 2 > vgl_h_matrix_2d< T >::get_upper_2x2_matrix ( ) const

corresponds to rotation for Euclidean transformations.

Definition at line 476 of file vgl_h_matrix_2d.hxx.

◆ is_euclidean()

template<class T >
bool vgl_h_matrix_2d< T >::is_euclidean ( ) const

Definition at line 302 of file vgl_h_matrix_2d.hxx.

◆ is_identity()

template<class T >
bool vgl_h_matrix_2d< T >::is_identity ( ) const

Definition at line 318 of file vgl_h_matrix_2d.hxx.

◆ is_rotation()

template<class T >
bool vgl_h_matrix_2d< T >::is_rotation ( ) const

Definition at line 294 of file vgl_h_matrix_2d.hxx.

◆ operator *() [1/3]

template<class T>
vgl_homg_point_2d<T> vgl_h_matrix_2d< T >::operator * ( vgl_homg_point_2d< T > const &  p) const
inline

Return the transformed point given by $q = {\tt H} p$.

Definition at line 72 of file vgl_h_matrix_2d.h.

◆ operator *() [2/3]

template<class T>
vgl_homg_line_2d<T> vgl_h_matrix_2d< T >::operator * ( vgl_homg_line_2d< T > const &  l) const
inline

Return the transformed line given by $m = {\tt H}^{-1} l$.

Definition at line 91 of file vgl_h_matrix_2d.h.

◆ operator *() [3/3]

template<class T>
vgl_h_matrix_2d<T> vgl_h_matrix_2d< T >::operator * ( vgl_h_matrix_2d< T > const &  H) const
inline

composition (*this) * H.

Definition at line 96 of file vgl_h_matrix_2d.h.

◆ operator()() [1/3]

template<class T>
vgl_homg_point_2d< T > vgl_h_matrix_2d< T >::operator() ( vgl_homg_point_2d< T > const &  p) const

Return the transformed point given by $q = {\tt H} p$.

Definition at line 88 of file vgl_h_matrix_2d.hxx.

◆ operator()() [2/3]

template<class T>
vgl_conic< T > vgl_h_matrix_2d< T >::operator() ( vgl_conic< T > const &  C) const

assumed to be a point conic.

Definition at line 120 of file vgl_h_matrix_2d.hxx.

◆ operator()() [3/3]

template<class T>
vgl_homg_line_2d< T > vgl_h_matrix_2d< T >::operator() ( vgl_homg_line_2d< T > const &  l) const

Return the transformed line given by $m = {\tt H}^{-1} l$.

Definition at line 157 of file vgl_h_matrix_2d.hxx.

◆ operator==()

template<class T>
bool vgl_h_matrix_2d< T >::operator== ( vgl_h_matrix_2d< T > const &  M) const
inline

Definition at line 74 of file vgl_h_matrix_2d.h.

◆ preimage() [1/3]

template<class T>
vgl_homg_line_2d< T > vgl_h_matrix_2d< T >::preimage ( vgl_homg_line_2d< T > const &  l) const

Return the transformed line given by $m = {\tt H} l$.

Definition at line 104 of file vgl_h_matrix_2d.hxx.

◆ preimage() [2/3]

template<class T>
vgl_homg_point_2d< T > vgl_h_matrix_2d< T >::preimage ( vgl_homg_point_2d< T > const &  q) const

Return the transformed point given by $p = {\tt H}^{-1} q$.

Definition at line 149 of file vgl_h_matrix_2d.hxx.

◆ preimage() [3/3]

template<class T>
vgl_conic< T > vgl_h_matrix_2d< T >::preimage ( vgl_conic< T > const &  C) const

assumed to be a point conic.

Definition at line 134 of file vgl_h_matrix_2d.hxx.

◆ projective_basis() [1/2]

template<class T>
bool vgl_h_matrix_2d< T >::projective_basis ( std::vector< vgl_homg_point_2d< T > > const &  four_points)

transformation to projective basis (canonical frame).

Compute the homography that takes the input set of points to the canonical frame. The points act as the projective basis for the canonical coordinate system. In the canonical frame the points have coordinates: $\begin{array}{cccc} p[0] & p[1] & p[2] & p[3] \% 1 & 0 & 0 & 1 \% 0 & 1 & 0 & 1 \% 0 & 0 & 1 & 1 \end{array}$

Definition at line 241 of file vgl_h_matrix_2d.hxx.

◆ projective_basis() [2/2]

template<class T>
bool vgl_h_matrix_2d< T >::projective_basis ( std::vector< vgl_homg_line_2d< T > > const &  four_lines)

transformation to projective basis (canonical frame).

Compute the homography that takes the input set of lines to the canonical frame. The lines act as the dual projective basis for the canonical coordinate system. In the canonical frame the lines have equations: x=0; y=0; w=0; x+y+w=0. (The third line is the line at infinity.)

Definition at line 325 of file vgl_h_matrix_2d.hxx.

◆ read() [1/2]

template<class T >
bool vgl_h_matrix_2d< T >::read ( std::istream &  s)

Read H from std::istream.

Definition at line 170 of file vgl_h_matrix_2d.hxx.

◆ read() [2/2]

template<class T >
bool vgl_h_matrix_2d< T >::read ( char const *  filename)

Read H from file.

Definition at line 177 of file vgl_h_matrix_2d.hxx.

◆ set() [1/3]

template<class T>
vgl_h_matrix_2d& vgl_h_matrix_2d< T >::set ( unsigned int  row_index,
unsigned int  col_index,
value 
)
inline

Set an element of the 3x3 homography matrix.

Definition at line 116 of file vgl_h_matrix_2d.h.

◆ set() [2/3]

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set ( T const *  M)

Set to 3x3 row-stored matrix.

Definition at line 223 of file vgl_h_matrix_2d.hxx.

◆ set() [3/3]

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set ( vnl_matrix_fixed< T, 3, 3 > const &  M)

Set to given 3x3 matrix.

Definition at line 232 of file vgl_h_matrix_2d.hxx.

◆ set_affine() [1/2]

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_affine ( vnl_matrix_fixed< T, 2, 3 > const &  M23)

set the transform to a general affine transform matrix.

$A = \left[ \begin{array}{ccc} a00 & a01 & a02 \% a10 & a11 & a12 \% 0 & 0 & 1 \end{array}\right]$

Definition at line 437 of file vgl_h_matrix_2d.hxx.

◆ set_affine() [2/2]

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_affine ( vnl_matrix< T > const &  M23)
Deprecated:
use the vnl_matrix_fixed variant instead

Definition at line 448 of file vgl_h_matrix_2d.hxx.

◆ set_aspect_ratio()

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_aspect_ratio ( aspect_ratio)

compose the transform with diagonal aspect ratio transform.

$A = \left[ \begin{array}{ccc} 1 & 0 & 0 \% 0 & a & 0 \% 0 & 0 & 1 \end{array}\right]$ , Ta = A*T.

Definition at line 427 of file vgl_h_matrix_2d.hxx.

◆ set_identity()

template<class T >
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_identity ( )

initialize the transformation to identity.

Definition at line 215 of file vgl_h_matrix_2d.hxx.

◆ set_rotation()

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_rotation ( theta)

the upper 2x2 part of the matrix is replaced by a rotation matrix.

rotation angle theta is in radians

Definition at line 393 of file vgl_h_matrix_2d.hxx.

◆ set_scale()

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_scale ( scale)

compose the current transform with a uniform scaling transformation, S.

$S = \left[ \begin{array}{ccc} s & 0 & 0 \% 0 & s & 0 \% 0 & 0 & 1 \end{array}\right]$ , Ts = S*T.

Definition at line 404 of file vgl_h_matrix_2d.hxx.

◆ set_similarity()

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_similarity ( s,
theta,
tx,
ty 
)

set the transform to a similarity mapping.

Sim $ = \left[\begin{array}{ccc} \cos(\theta) & -\sin(\theta) & tx \% \sin(\theta) & \cos(\theta) & ty \% 0 & 0 & 1 \end{array}\right]$

Definition at line 414 of file vgl_h_matrix_2d.hxx.

◆ set_translation()

template<class T>
vgl_h_matrix_2d< T > & vgl_h_matrix_2d< T >::set_translation ( tx,
ty 
)

set H[0][2] = tx and H[1][2] = ty, other elements unaltered.

Definition at line 385 of file vgl_h_matrix_2d.hxx.

Member Data Documentation

◆ t12_matrix_

template<class T>
vnl_matrix_fixed<T,3,3> vgl_h_matrix_2d< T >::t12_matrix_
protected

Definition at line 42 of file vgl_h_matrix_2d.h.


The documentation for this class was generated from the following files: