GDAL

- Main Page
- Related Pages
- Classes
- Files
- Download
- Issue Tracker

- File List
- File Members

gdal_simplesurf.h
Go to the documentation of this file.
1 /******************************************************************************
2 * $Id$
3 * Project: GDAL
4 * Purpose: Correlator
5 * Author: Andrew Migal, migal.drew@gmail.com
6 *
7 ******************************************************************************
8 * Copyright (c) 2012, Andrew Migal
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 ****************************************************************************/
28
35 #ifndef GDALSIMPLESURF_H_
36 #define GDALSIMPLESURF_H_
37
38 #include "gdal_priv.h"
39 #include "cpl_conv.h"
40 #include <list>
41
50 class GDALFeaturePoint
51 {
52 public:
57 GDALFeaturePoint();
58
63 GDALFeaturePoint(const GDALFeaturePoint& fp);
64
77 GDALFeaturePoint(int nX, int nY, int nScale, int nRadius, int nSign);
78 virtual ~GDALFeaturePoint();
79
81 GDALFeaturePoint& operator=(const GDALFeaturePoint& point);
82
92 double& operator[](int nIndex);
93
95 static const int DESC_SIZE = 64;
96
102 int GetX() const;
103
109 void SetX(int nX);
110
116 int GetY() const;
117
123 void SetY(int nY);
124
130 int GetScale() const ;
131
137 void SetScale(int nScale);
138
144 int GetRadius() const;
145
151 void SetRadius(int nRadius);
152
158 int GetSign() const;
159
165 void SetSign(int nSign);
166
167 private:
168 // Coordinates of point in image
169 int nX;
170 int nY;
171 // --------------------
172 int nScale;
173 int nRadius;
174 int nSign;
175 // Descriptor array
176 double *padfDescriptor;
177 };
178
188 class GDALIntegralImage
189 {
190 public:
191 GDALIntegralImage();
192 virtual ~GDALIntegralImage();
193
201 void Initialize(const double **padfImg, int nHeight, int nWidth);
202
211 double GetValue(int nRow, int nCol);
212
224 double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight);
225
235 double HaarWavelet_X(int nRow, int nCol, int nSize);
236
246 double HaarWavelet_Y(int nRow, int nCol, int nSize);
247
253 int GetHeight();
254
260 int GetWidth();
261
262 private:
263 double **pMatrix;
264 int nWidth;
265 int nHeight;
266 };
267
276 class GDALOctaveLayer
277 {
278 public:
279 GDALOctaveLayer();
280
289 GDALOctaveLayer(int nOctave, int nInterval);
290 virtual ~GDALOctaveLayer();
291
301 void ComputeLayer(GDALIntegralImage *poImg);
302
306 int octaveNum;
310 int filterSize;
314 int radius;
318 int scale;
322 int width;
326 int height;
330 double **detHessians;
334 int **signs;
335 };
336
343 class GDALOctaveMap
344 {
345 CPL_DISALLOW_COPY_ASSIGN( GDALOctaveMap )
346
347 public:
354 GDALOctaveMap(int nOctaveStart, int nOctaveEnd);
355 virtual ~GDALOctaveMap();
356
363 void ComputeMap(GDALIntegralImage *poImg);
364
382 static bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot,
383 GDALOctaveLayer *mid, GDALOctaveLayer *top, double threshold);
384
388 GDALOctaveLayer ***pMap;
389
393 static const int INTERVALS = 4;
394
398 int octaveStart;
399
403 int octaveEnd;
404 };
405
417 class GDALSimpleSURF
418 {
419 private:
424 class MatchedPointPairInfo
425 {
426 public:
427 MatchedPointPairInfo(int nInd_1, int nInd_2, double dfDist)
428 {
429 ind_1 = nInd_1;
430 ind_2 = nInd_2;
431 euclideanDist = dfDist;
432 }
433
434 int ind_1;
435 int ind_2;
436 double euclideanDist;
437 };
438
439 CPL_DISALLOW_COPY_ASSIGN( GDALSimpleSURF )
440
441 public:
463 GDALSimpleSURF(int nOctaveStart, int nOctaveEnd);
464 virtual ~GDALSimpleSURF();
465
482 static CPLErr ConvertRGBToLuminosity(
483 GDALRasterBand *red,
484 GDALRasterBand *green,
485 GDALRasterBand *blue,
486 int nXSize, int nYSize,
487 double **padfImg, int nHeight, int nWidth);
488
503 std::vector<GDALFeaturePoint>*
504 ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold);
505
518 static CPLErr MatchFeaturePoints(
519 std::vector<GDALFeaturePoint*> *poMatchPairs,
520 std::vector<GDALFeaturePoint> *poFirstCollect,
521 std::vector<GDALFeaturePoint> *poSecondCollect,
522 double dfThreshold);
523
524 private:
534 static double GetEuclideanDistance(
535 GDALFeaturePoint &firstPoint, GDALFeaturePoint &secondPoint);
536
542 static void NormalizeDistances(std::list<MatchedPointPairInfo> *poList);
543
550 static void SetDescriptor(GDALFeaturePoint *poPoint, GDALIntegralImage *poImg);
551
552 private:
553 int octaveStart;
554 int octaveEnd;
555 GDALOctaveMap *poOctMap;
556 };
557
558 #endif /* GDALSIMPLESURF_H_ */
GDALSimpleSURF::ExtractFeaturePoints
std::vector< GDALFeaturePoint > * ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold)
Find feature points using specified integral image.
Definition: gdal_simplesurf.cpp:213
GDALFeaturePoint::operator=
GDALFeaturePoint & operator=(const GDALFeaturePoint &point)
Assignment operator.
Definition: gdal_simplesurf.cpp:71
GDALOctaveLayer::octaveNum
int octaveNum
Octave which contains this layer (1,2,3...)
Definition: gdal_simplesurf.h:306
GDALOctaveLayer::height
int height
Image height in pixels.
Definition: gdal_simplesurf.h:326
GDALIntegralImage::GetHeight
int GetHeight()
Fetch height of integral image.
Definition: gdal_octave.cpp:45
gdal_priv.h
C++ GDAL entry points.
GDALOctaveMap
Class for handling octave layers in SURF-based algorithm.
Definition: gdal_simplesurf.h:343
GDALOctaveLayer::scale
int scale
Scale for this layer.
Definition: gdal_simplesurf.h:318
GDALOctaveMap::GDALOctaveMap
GDALOctaveMap(int nOctaveStart, int nOctaveEnd)
Create octave space.
Definition: gdal_octave.cpp:249
GDALFeaturePoint::SetSign
void SetSign(int nSign)
Set sign of point.
Definition: gdal_simplesurf.cpp:106
GDALSimpleSURF
Class for searching corresponding points on images.
Definition: gdal_simplesurf.h:417
GDALFeaturePoint::SetScale
void SetScale(int nScale)
Set scale of point.
Definition: gdal_simplesurf.cpp:100
GDALIntegralImage::HaarWavelet_X
double HaarWavelet_X(int nRow, int nCol, int nSize)
Get value of horizontal Haar wavelet in specified square grid.
Definition: gdal_octave.cpp:138
GDALFeaturePoint
Class of "feature point" in raster.
Definition: gdal_simplesurf.h:50
GDALOctaveLayer::detHessians
double ** detHessians
Hessian values for image pixels.
Definition: gdal_simplesurf.h:330
GDALFeaturePoint::GetX
int GetX() const
Fetch X-coordinate (pixel) of point.
Definition: gdal_simplesurf.cpp:93
GDALOctaveMap::pMap
GDALOctaveLayer *** pMap
2-dimensional array of octave layers
Definition: gdal_simplesurf.h:388
GDALIntegralImage::Initialize
void Initialize(const double **padfImg, int nHeight, int nWidth)
Compute integral image for specified array.
Definition: gdal_octave.cpp:49
GDALFeaturePoint::GDALFeaturePoint
GDALFeaturePoint()
Standard constructor.
Definition: gdal_simplesurf.cpp:40
GDALIntegralImage::HaarWavelet_Y
double HaarWavelet_Y(int nRow, int nCol, int nSize)
Get value of vertical Haar wavelet in specified square grid.
Definition: gdal_octave.cpp:144
GDALIntegralImage::GetRectangleSum
double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight)
Get sum of values in specified rectangular grid.
Definition: gdal_octave.cpp:99
GDALOctaveLayer::radius
int radius
Length of the border.
Definition: gdal_simplesurf.h:314
GDALFeaturePoint::GetScale
int GetScale() const
Fetch scale of point.
Definition: gdal_simplesurf.cpp:99
GDALFeaturePoint::GetSign
int GetSign() const
Fetch sign of Hessian determinant of point.
Definition: gdal_simplesurf.cpp:105
GDALOctaveMap::ComputeMap
void ComputeMap(GDALIntegralImage *poImg)
Calculate Hessian values for octave space (for all stored octave layers) using specified integral ima...
Definition: gdal_octave.cpp:262
GDALFeaturePoint::SetY
void SetY(int nY)
Set Y coordinate of point.
Definition: gdal_simplesurf.cpp:97
GDALSimpleSURF::ConvertRGBToLuminosity
static CPLErr ConvertRGBToLuminosity(GDALRasterBand *red, GDALRasterBand *green, GDALRasterBand *blue, int nXSize, int nYSize, double **padfImg, int nHeight, int nWidth)
Convert image with RGB channels to grayscale using "luminosity" method.
Definition: gdal_simplesurf.cpp:137
GDALIntegralImage
Integral image class (summed area table).
Definition: gdal_simplesurf.h:188
GDALFeaturePoint::GetY
int GetY() const
Fetch Y-coordinate (line) of point.
Definition: gdal_simplesurf.cpp:96
GDALIntegralImage::GetWidth
int GetWidth()
Fetch width of integral image.
Definition: gdal_octave.cpp:47
GDALFeaturePoint::operator[]
double & operator[](int nIndex)
Provide access to point's descriptor.
Definition: gdal_simplesurf.cpp:108
GDALOctaveLayer::signs
int ** signs
Hessian signs for speeded matching.
Definition: gdal_simplesurf.h:334
GDALOctaveLayer::width
int width
Image width in pixels.
Definition: gdal_simplesurf.h:322
GDALOctaveLayer::ComputeLayer
void ComputeLayer(GDALIntegralImage *poImg)
Perform calculation of Hessian determinants and their signs for specified integral image...
Definition: gdal_octave.cpp:176
GDALIntegralImage::GetValue
double GetValue(int nRow, int nCol)
Fetch value of specified position in integral image.
Definition: gdal_octave.cpp:91
cpl_conv.h
Various convenience functions for CPL.
GDALOctaveMap::octaveEnd
int octaveEnd
Number of top octave.
Definition: gdal_simplesurf.h:403
GDALOctaveLayer::filterSize
int filterSize
Length of the side of filter.
Definition: gdal_simplesurf.h:310
GDALFeaturePoint::GetRadius
int GetRadius() const
Fetch radius of point.
Definition: gdal_simplesurf.cpp:102
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1042
GDALFeaturePoint::DESC_SIZE
static const int DESC_SIZE
Descriptor length.
Definition: gdal_simplesurf.h:95
GDALFeaturePoint::SetRadius
void SetRadius(int nRadius)
Set radius of point.
Definition: gdal_simplesurf.cpp:103
GDALOctaveMap::octaveStart
int octaveStart
Number of bottom octave.
Definition: gdal_simplesurf.h:398
GDALOctaveLayer
Class for computation and storage of Hessian values in SURF-based algorithm.
Definition: gdal_simplesurf.h:276
GDALOctaveMap::INTERVALS
static const int INTERVALS
Value for constructing internal octave space.
Definition: gdal_simplesurf.h:393
GDALSimpleSURF::MatchFeaturePoints
static CPLErr MatchFeaturePoints(std::vector< GDALFeaturePoint * > *poMatchPairs, std::vector< GDALFeaturePoint > *poFirstCollect, std::vector< GDALFeaturePoint > *poSecondCollect, double dfThreshold)
Find corresponding points (equal points in two collections).
Definition: gdal_simplesurf.cpp:365
GDALFeaturePoint::SetX
void SetX(int nX)
Set X coordinate of point.
Definition: gdal_simplesurf.cpp:94
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:52
GDALSimpleSURF::GDALSimpleSURF
GDALSimpleSURF(int nOctaveStart, int nOctaveEnd)
Prepare class according to specified parameters.
Definition: gdal_simplesurf.cpp:129
CPL_DISALLOW_COPY_ASSIGN
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:987
GDALOctaveMap::PointIsExtremum
static bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot, GDALOctaveLayer *mid, GDALOctaveLayer *top, double threshold)
Method makes decision that specified point in middle octave layer is maximum among all points from 3x...
Definition: gdal_octave.cpp:269

Generated for GDAL by 1.8.8.