Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HomographyMapping.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #include <Base/Common/BIASpragmaStart.hh>
26 
27 #ifndef __HomographyMapping_hh__
28 #define __HomographyMapping_hh__
29 
30 #include <Image/BackwardMapping.hh>
31 #include <Geometry/HMatrix.hh>
32 
33 
34 namespace BIAS {
35 
36  /** @class HomographyMapping
37  @ingroup g_filter
38  @brief Maps image src to image sink with homography H (software
39  implementation)
40  @author koeser, edited by grest Nov. 2005
41  */
42  template <class InputStorageType, class OutputStorageType>
43  class BIASImage_EXPORT HomographyMapping
44  : public BackwardMapping<InputStorageType, OutputStorageType> {
45  public:
46 
47  virtual ~HomographyMapping();
48 
50 
51  /** required because assignment is
52  @author Jan Woetzel */
54 
55  /** required because of const members
56  @author Jan Woetzel */
58  operator=(const HomographyMapping & src);
59 
60  /** @brief set your homography H (source = H * sink) before calling Map()*/
61  inline void SetHomography(const HMatrix& H) { H_ = H; };
62 
63 
64 
65  /** calculates the bounding box in sink image,
66  where to do the backward mapping.
67  The resulting coordinates must be valid in sink, and the resulting
68  br position should be outside the region.
69  @author grest, Nov. 2005
70  */
71  virtual int GetBoundingBox(unsigned int srcwidth, unsigned int srcheight,
72  unsigned int sinkwidth, unsigned int sinkheight,
73  int &tlx, int &tly,
74  int &brx, int &bry);
75 
76  /** if Map() is called with newDist=true, the real applied Homography
77  is changed
78  */
79  HMatrix GetChangedHomography() const;
80 
81  protected:
82  /** @brief reimplementation for homography, takes sink and computes
83  coords in source */
84  virtual int GetSourceCoordinates_(const HomgPoint2D& sink,
85  HomgPoint2D& source) const;
86 
87  /** @brief analytic jacobian */
88  virtual int GetJacobian_(const HomgPoint2D& sink,
89  Matrix2x2<double>& Jacobian) const;
90 
91  /// the homography for backward mapping: run over sink and compute
92  /// source = H_ * sink
94 
97  };
98 
99 
100  //
101  //#ifdef WIN32
102  //template <>
103  //int HomographyMapping<unsigned char, unsigned char>::
104  //Map(Image<unsigned char> &source, Image<unsigned char> &dest,
105  // const HMatrix& H);
106  //#endif
107  //
108 
109 } // namespace
110 
111 #endif
112 
113 #include <Base/Common/BIASpragmaEnd.hh>
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
a 3x3 Matrix describing projective transformations between planes
Definition: HMatrix.hh:39
Maps image src to image sink with homography H (software implementation)
Abstract base class to map an image (texture) src to an image sink with an arbitrary continuous funct...
HMatrix H_
the homography for backward mapping: run over sink and compute source = H_ * sink ...
void SetHomography(const HMatrix &H)
set your homography H (source = H * sink) before calling Map()