GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

gdal_simplesurf.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Project: GDAL
3 * Purpose: Correlator
4 * Author: Andrew Migal, migal.drew@gmail.com
5 *
6 ******************************************************************************
7 * Copyright (c) 2012, Andrew Migal
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 ****************************************************************************/
27
34 #ifndef GDALSIMPLESURF_H_
35 #define GDALSIMPLESURF_H_
36
37 #include "gdal_priv.h"
38 #include "cpl_conv.h"
39 #include <list>
40
49 class GDALFeaturePoint
50 {
51 public:
56 GDALFeaturePoint();
57
62 GDALFeaturePoint(const GDALFeaturePoint& fp);
63
76 GDALFeaturePoint(int nX, int nY, int nScale, int nRadius, int nSign);
77 virtual ~GDALFeaturePoint();
78
79 GDALFeaturePoint& operator=(const GDALFeaturePoint& point);
80
90 double& operator[](int nIndex);
91
92 // Descriptor length
93 static const int DESC_SIZE = 64;
94
100 int GetX();
101
107 void SetX(int nX);
108
114 int GetY();
115
121 void SetY(int nY);
122
128 int GetScale();
129
135 void SetScale(int nScale);
136
142 int GetRadius();
143
149 void SetRadius(int nRadius);
150
156 int GetSign();
157
163 void SetSign(int nSign);
164
165 private:
166 // Coordinates of point in image
167 int nX;
168 int nY;
169 // --------------------
170 int nScale;
171 int nRadius;
172 int nSign;
173 // Descriptor array
174 double *padfDescriptor;
175 };
176
186 class GDALIntegralImage
187 {
188 public:
189 GDALIntegralImage();
190 virtual ~GDALIntegralImage();
191
199 void Initialize(const double **padfImg, int nHeight, int nWidth);
200
209 double GetValue(int nRow, int nCol);
210
222 double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight);
223
233 double HaarWavelet_X(int nRow, int nCol, int nSize);
234
244 double HaarWavelet_Y(int nRow, int nCol, int nSize);
245
251 int GetHeight();
252
258 int GetWidth();
259
260 private:
261 double **pMatrix;
262 int nWidth;
263 int nHeight;
264 };
265
274 class GDALOctaveLayer
275 {
276 public:
277 GDALOctaveLayer();
278
287 GDALOctaveLayer(int nOctave, int nInterval);
288 virtual ~GDALOctaveLayer();
289
299 void ComputeLayer(GDALIntegralImage *poImg);
300
304 int octaveNum;
308 int filterSize;
312 int radius;
316 int scale;
320 int width;
324 int height;
328 double **detHessians;
332 int **signs;
333 };
334
341 class GDALOctaveMap
342 {
343 public:
350 GDALOctaveMap(int nOctaveStart, int nOctaveEnd);
351 virtual ~GDALOctaveMap();
352
359 void ComputeMap(GDALIntegralImage *poImg);
360
378 bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot,
379 GDALOctaveLayer *mid, GDALOctaveLayer *top, double threshold);
380
384 GDALOctaveLayer ***pMap;
385
389 static const int INTERVALS = 4;
390
394 int octaveStart;
395
399 int octaveEnd;
400 };
401
413 class GDALSimpleSURF
414 {
415 private:
420 class MatchedPointPairInfo
421 {
422 public:
423 MatchedPointPairInfo(int nInd_1, int nInd_2, double dfDist)
424 {
425 ind_1 = nInd_1;
426 ind_2 = nInd_2;
427 euclideanDist = dfDist;
428 }
429
430 int ind_1;
431 int ind_2;
432 double euclideanDist;
433 };
434
435 public:
457 GDALSimpleSURF(int nOctaveStart, int nOctaveEnd);
458 virtual ~GDALSimpleSURF();
459
476 static CPLErr ConvertRGBToLuminosity(
477 GDALRasterBand *red,
478 GDALRasterBand *green,
479 GDALRasterBand *blue,
480 int nXSize, int nYSize,
481 double **padfImg, int nHeight, int nWidth);
482
497 std::vector<GDALFeaturePoint>*
498 ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold);
499
512 static CPLErr MatchFeaturePoints(
513 std::vector<GDALFeaturePoint*> *poMatchPairs,
514 std::vector<GDALFeaturePoint> *poFirstCollect,
515 std::vector<GDALFeaturePoint> *poSecondCollect,
516 double dfThreshold);
517
518 private:
528 static double GetEuclideanDistance(
529 GDALFeaturePoint &firstPoint, GDALFeaturePoint &secondPoint);
530
536 static void NormalizeDistances(std::list<MatchedPointPairInfo> *poList);
537
544 void SetDescriptor(GDALFeaturePoint *poPoint, GDALIntegralImage *poImg);
545
546
547 private:
548 int octaveStart;
549 int octaveEnd;
550 GDALOctaveMap *poOctMap;
551 };
552
553
554 #endif /* GDALSIMPLESURF_H_ */
GDALSimpleSURF::ExtractFeaturePoints
std::vector< GDALFeaturePoint > * ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold)
Find feature points using specified integral image.
Definition: gdal_simplesurf.cpp:214
GDALFeaturePoint::GetY
int GetY()
Fetch Y-coordinate (line) of point.
Definition: gdal_simplesurf.cpp:99
GDALOctaveLayer::octaveNum
int octaveNum
Octave which contains this layer (1,2,3...)
Definition: gdal_simplesurf.h:304
GDALOctaveLayer::height
int height
Image height in pixels.
Definition: gdal_simplesurf.h:324
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:341
GDALOctaveLayer::scale
int scale
Scale for this layer.
Definition: gdal_simplesurf.h:316
GDALOctaveMap::GDALOctaveMap
GDALOctaveMap(int nOctaveStart, int nOctaveEnd)
Create octave space.
Definition: gdal_octave.cpp:234
GDALFeaturePoint::SetSign
void SetSign(int nSign)
Set sign of point.
Definition: gdal_simplesurf.cpp:109
GDALSimpleSURF
Class for searching corresponding points on images.
Definition: gdal_simplesurf.h:413
GDALFeaturePoint::SetScale
void SetScale(int nScale)
Set scale of point.
Definition: gdal_simplesurf.cpp:103
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:124
GDALFeaturePoint
Class of "feature point" in raster.
Definition: gdal_simplesurf.h:49
GDALOctaveLayer::detHessians
double ** detHessians
Hessian values for image pixels.
Definition: gdal_simplesurf.h:328
GDALOctaveMap::pMap
GDALOctaveLayer *** pMap
2-dimensional array of octave layers
Definition: gdal_simplesurf.h:384
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:38
GDALFeaturePoint::GetSign
int GetSign()
Fetch sign of Hessian determinant of point.
Definition: gdal_simplesurf.cpp:108
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:130
GDALIntegralImage::GetRectangleSum
double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight)
Get sum of values in specified rectangular grid.
Definition: gdal_octave.cpp:89
GDALFeaturePoint::GetRadius
int GetRadius()
Fetch radius of point.
Definition: gdal_simplesurf.cpp:105
GDALOctaveLayer::radius
int radius
Length of the border.
Definition: gdal_simplesurf.h:312
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:249
GDALFeaturePoint::SetY
void SetY(int nY)
Set Y coordinate of point.
Definition: gdal_simplesurf.cpp:100
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:141
GDALIntegralImage
Integral image class (summed area table).
Definition: gdal_simplesurf.h:186
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:111
GDALOctaveLayer::signs
int ** signs
Hessian signs for speeded matching.
Definition: gdal_simplesurf.h:332
GDALOctaveLayer::width
int width
Image width in pixels.
Definition: gdal_simplesurf.h:320
GDALOctaveLayer::ComputeLayer
void ComputeLayer(GDALIntegralImage *poImg)
Perform calculation of Hessian determinants and their signs for specified integral image...
Definition: gdal_octave.cpp:166
GDALIntegralImage::GetValue
double GetValue(int nRow, int nCol)
Fetch value of specified position in integral image.
Definition: gdal_octave.cpp:81
cpl_conv.h
Various convenience functions for CPL.
GDALFeaturePoint::GetX
int GetX()
Fetch X-coordinate (pixel) of point.
Definition: gdal_simplesurf.cpp:96
GDALOctaveMap::octaveEnd
int octaveEnd
Number of top octave.
Definition: gdal_simplesurf.h:399
GDALOctaveLayer::filterSize
int filterSize
Length of the side of filter.
Definition: gdal_simplesurf.h:308
GDALFeaturePoint::GetScale
int GetScale()
Fetch scale of point.
Definition: gdal_simplesurf.cpp:102
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:735
GDALFeaturePoint::SetRadius
void SetRadius(int nRadius)
Set radius of point.
Definition: gdal_simplesurf.cpp:106
GDALOctaveMap::octaveStart
int octaveStart
Number of bottom octave.
Definition: gdal_simplesurf.h:394
GDALOctaveLayer
Class for computation and storage of Hessian values in SURF-based algorithm.
Definition: gdal_simplesurf.h:274
GDALOctaveMap::INTERVALS
static const int INTERVALS
Value for constructing internal octave space.
Definition: gdal_simplesurf.h:389
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:360
GDALFeaturePoint::SetX
void SetX(int nX)
Set X coordinate of point.
Definition: gdal_simplesurf.cpp:97
GDALSimpleSURF::GDALSimpleSURF
GDALSimpleSURF(int nOctaveStart, int nOctaveEnd)
Prepare class according to specified parameters.
Definition: gdal_simplesurf.cpp:132
GDALOctaveMap::PointIsExtremum
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:256

Generated for GDAL by 1.8.8.