contrib/gel/mrc/vpgl/vpgl_lens_distortion.h
Go to the documentation of this file.
00001 // This is gel/mrc/vpgl/vpgl_lens_distortion.h
00002 #ifndef vpgl_lens_distortion_h_
00003 #define vpgl_lens_distortion_h_
00004 //:
00005 // \file
00006 // \brief An abstract base class for all lens distortions.
00007 // \author Matt Leotta
00008 // \date August 19, 2005
00009 //
00010 //   A lens distortion is a 2D warping of the image plane to account for lens effects
00011 //   not accounted for by the simple camera models.  It is assumed that the map is
00012 //   bijective, though a closed form solution for the inverse may not exist in general.
00013 //   A default iterative solver is implemented to solve
00014 
00015 //: forward declare vgl_homg_point_2d<T> and vgl_vector_2d<T>
00016 #include <vgl/vgl_fwd.h>
00017 
00018 //: A base class for lens distortions
00019 template <class T>
00020 class vpgl_lens_distortion
00021 {
00022  public:
00023 
00024   virtual ~vpgl_lens_distortion(){}
00025 
00026   //: Distort a projected point on the image plane
00027   virtual vgl_homg_point_2d<T> distort( const vgl_homg_point_2d<T>& point ) const = 0;
00028 
00029   //: Return the original point that was distorted to this location (inverse of distort)
00030   // \param init is an initial guess at the solution for the iterative solver
00031   // if \p init is NULL then \p point is used as the initial guess
00032   virtual vgl_homg_point_2d<T> undistort( const vgl_homg_point_2d<T>& point,
00033                                           const vgl_homg_point_2d<T>* init=0) const;
00034 
00035   //: Set a translation to apply before of after distortion
00036   // This is needed when distorting an image to translate the resulting image
00037   // such that all points have positive indices
00038   virtual void set_translation(const vgl_vector_2d<T>& offset, bool after = true) = 0;
00039 };
00040 
00041 
00042 #endif // vpgl_lens_distortion_h_