Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CornerDetectorFoerstner.cpp
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 "CornerDetectorFoerstner.hh"
26 
27 using namespace std;
28 using namespace BIAS;
29 
30 //////////////////////////////////////////////////////////////////////////
31 // implementation
32 //////////////////////////////////////////////////////////////////////////
33 
34 template <class StorageType, class CalculationType>
37 CornerDetectorGradient<StorageType,
38  CalculationType>()
39 {
40 }
41 
42 template <class StorageType, class CalculationType>
45 {
46 }
47 
48 template <class StorageType, class CalculationType> int
51 {
52  // preserver ROI
53  int tlx, tly, brx, bry;
54  this->_sgxx.GetROI()->GetCorners(tlx, tly, brx, bry);
55  Cornerness.GetROI()->SetCorners(tlx, tly, brx, bry);
56 
57  const unsigned int width=Cornerness.GetWidth();
58  const unsigned int height=Cornerness.GetHeight();
59 
60  // work pointers to summed multiplied derivatives
61  CalculationType *psgxx=this->_sgxx.GetImageData(),
62  *psgyy=this->_sgyy.GetImageData(),
63  *psgxy=this->_sgxy.GetImageData();
64  CalculationType *ptr, *end, tmp;
65 
66  // init min und max with impossible values
67  //_max = FLT_MIN;
68  //_min = FLT_MAX;
69 
70  // init all pointers to first usable position (skip upper two lines)
71  /// \todo use ROI instead of border=2
72  unsigned offs = 2*width+2;
73  unsigned int x=2,y=2;
74  ptr = Cornerness.GetImageData()+offs;
75  psgxx += offs;
76  psgxy += offs;
77  psgyy += offs;
78  end = Cornerness.GetImageData()+width*(height-2)-2;
79  const double me=(double)this->_MinCornerness;
80  Feat fp;
81  this->_FeatList.clear();
82  this->_FeatList.reserve(end-ptr);
83  // run over all pixels, dont care about borders
84  // run over all pixels, dont care about borders
85  while (ptr<end) {
86  const CalculationType xx = (CalculationType) *psgxx++;
87  const CalculationType xy = (CalculationType) *psgxy++;
88  const CalculationType yy = (CalculationType) *psgyy++;
89 
90  // cornerness = det / trace
91  tmp = xx*yy-xy*xy / (xx+yy);
92 
93  // save highest/lowest values for quality analysis later
94  //if (tmp>_max) _max = tmp;
95  //else if (tmp<_min) _min=tmp;
96  if (tmp*(CalculationType)4.0/(xx+yy)>me){
97  fp.x=x;
98  fp.y=y;
99  fp.val=(tmp>(double)INT_MAX)?(INT_MAX):((int)tmp);
100  this->_FeatList.push_back(fp);
101  //cout <<"Found a point above min cornerness: "<<endl;
102  }
103  *ptr++ = tmp;
104  if (++x>=width){
105  y++;
106  x=0;
107  }
108  }
109  return 0;
110 }
111 
112 //////////////////////////////////////////////////////////////////////////
113 // instantiation
114 //////////////////////////////////////////////////////////////////////////
115 namespace BIAS{
118 
119 // fill in instances as required
120 #ifdef BUILD_IMAGE_INT
122 #endif
123 #ifdef BUILD_IMAGE_CHAR
125 #endif
126 #ifdef BUILD_IMAGE_SHORT
127 #endif
128 #ifdef BUILD_IMAGE_USHORT
130 #ifdef BUILD_IMAGE_INT
132 #endif
133 #endif
134 #ifdef BUILD_IMAGE_UINT
135 #endif
136 #ifdef BUILD_IMAGE_DOUBLE
137 #endif
138 }
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
Definition: ROI.cpp:287
unsigned int GetWidth() const
Definition: ImageBase.hh:312
foerstner corner detector, detects grey value corners in images
virtual int _ComputeCornerness(Image< CalculationType > &im)
Computes the Foerstner cornerness criterion det/trace, points are accepted only if corner-ellipse is ...
ROI * GetROI()
Returns a pointer to the roi object.
Definition: ImageBase.hh:615
unsigned int GetHeight() const
Definition: ImageBase.hh:319
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
Definition: Image.hh:137
base class for all gradient based corner detectors