Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CornerMatcher.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 
26 #ifndef __CornerMatcher_hh__
27 #define __CornerMatcher_hh__
28 #include "bias_config.h"
29 
30 #include <Base/Geometry/HomgPoint2D.hh>
31 #include <Base/Image/Image.hh>
32 #include <Base/Image/Image.hh>
33 #include <Image/PyramidImage.hh>
34 #include "RegionMatcher.hh"
35 
36 #define D_CORNER_MATCHER_SEARCH 0x0010
37 #define D_CORNER_MATCHER_KLT 0x0020
38 #define D_CORNER_MATCHER_PARABOLA 0x0040
39 #define D_CORNER_MATCHER_PYKLT 0x0080
40 
41 namespace BIAS {
42 
43  /** @class CornerMatcher
44  @ingroup g_corresp
45  @brief class with various functions to detect corresponding image points.
46  This class implements SSD, NCC
47  */
48  class BIASMatcher2D_EXPORT CornerMatcher : public RegionMatcher
49  {
50  public:
51 
52  CornerMatcher();
53 
54  ~CornerMatcher();
55 
56  /** wrapper for SSD from RegionMatcher, does boundary checks
57  and casts uses rint to determine location of ssd*/
58  template <class StorageType>
59  int SSD(const HomgPoint2D& p1, const HomgPoint2D& p2,
60  const Image<StorageType>& im1, const Image<StorageType>& im2,
61  const unsigned int halfwinsize, double& result) const;
62 
63  /** wrapper for NCC from RegionMatcher, does boundary checks
64  and casts uses rint to determine location of ncc */
65  template <class StorageType>
66  int NCC(const HomgPoint2D& p1, const HomgPoint2D& p2,
67  const Image<StorageType>& im1, const Image<StorageType>& im2,
68  const unsigned int halfwinsize, double& result) const;
69 
70  /** wrapper for RegionMatcher::NCCSearchOdd/NCCSearchEven,
71  does boundary checks and casts */
72  template <class StorageType>
73  int NCCSearch(const HomgPoint2D& p1, const HomgPoint2D& p2,
74  const Image<StorageType>& im1, const Image<StorageType>& im2,
75  const unsigned int halfnccwinsizeconst,
76  const unsigned int halfsearchwinsize,
77  HomgPoint2D& resultpoint,
78  const double mincorrelation,
79  double & result );
80 
81  /** wrapper with range checking for RegionMatcher::KLT
82  for a description see RegionMatcher::KLT
83  gradientborder is the halfwinsize of the gradient filter mask */
84  // template <class StorageType>
85 // int KLT(HomgPoint2D& p1, HomgPoint2D& p2, Image<StorageType>& im1,
86 // Image<StorageType>& im2, Image<StorageType>& gradx,
87 // Image<StorageType>& grady, unsigned int halfwinsize,
88 // unsigned int gradientborder, unsigned int numiterations,
89 // HomgPoint2D& result, KLT_TYPE& error);
90 
91 // /** as above, but iterates until either maxerror or maxnumiterations is
92 // reached */
93 // template <class StorageType>
94 // int KLT(HomgPoint2D& p1, HomgPoint2D& p2, Image<StorageType>& im1,
95 // Image<StorageType>& im2, Image<StorageType>& gradx,
96 // Image<StorageType>& grady, unsigned int halfwinsize,
97 // unsigned int gradientborder, unsigned int maxnumiterations,
98 // KLT_TYPE maxerror, HomgPoint2D& result, KLT_TYPE& error);
99 
100 // /** wrapper for RegionMatcher::KLT2 and pyramid images
101 // @authopr woelk 10/2003 */
102 // template <class StorageType>
103 // int KLT2(KLT_TYPE p1[2], KLT_TYPE p2[2], PyramidImage2<StorageType>& im1,
104 // PyramidImage2<StorageType>& im2, PyramidImage2<StorageType>& gx1,
105 // PyramidImage2<StorageType>& gy1, PyramidImage2<StorageType>& gx2,
106 // PyramidImage2<StorageType>& gy2, unsigned pyindex, unsigned hws,
107 // unsigned maxiterations, double SADThresh, KLT_TYPE maxerror,
108 // KLT_TYPE res[2], KLT_TYPE& error);
109 
110  /** wrapper for RegionMatcher::ParabolaNCC */
111  template <class StorageType>
112  int ParabolaNCC(const HomgPoint2D& p1, const HomgPoint2D& p2,
113  const Image<StorageType>& im1,
114  const Image<StorageType>& im2,
115  const unsigned int halfwinsize,
116  HomgPoint2D& result) const;
117 
118  /** wrapper for RegionMatcher::ParabolaNCC5 */
119  template <class StorageType>
120  int ParabolaNCC5(const HomgPoint2D& p1, const HomgPoint2D& p2,
121  const Image<StorageType>& im1,
122  const Image<StorageType>& im2,
123  const unsigned int halfwinsize,
124  HomgPoint2D& result) const;
125 
126  /** Assumes that ps1 is fully filled.
127  The matches on the smallest pyramid level must be given,
128  i.e. matches[im1.size()-1][i] must correspond to ps1[im1.size()-1][i]
129  with correlation quality matchquality[i].
130  It then propagates the matches to the upper (bigger) pyramid levels
131  using ncc correlation.
132  @author woelk 05 2003 */
133  template <class StorageType>
134  int RefinePyramideNCC(std::vector<std::vector<HomgPoint2D> >& ps1,
137  unsigned int halfnccwinsize,
138  std::vector<std::vector<HomgPoint2D> >& matches,
139  std::vector<std::vector<double> >& matchquality);
140 
141 
142  }; // class
143 } // namespace
144 #endif // __CornerMatcher_hh__
class HomgPoint2D describes a point with 2 degrees of freedom in projective coordinates.
Definition: HomgPoint2D.hh:67
The image template class for specific storage types.
Definition: Image.hh:78
Basic functions for CornerMatcher.
class with various functions to detect corresponding image points.