GDAL

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 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
19#ifndef GDALSIMPLESURF_H_
20#define GDALSIMPLESURF_H_
21
22#include "gdal_priv.h"
23#include "cpl_conv.h"
24#include <list>
25
35 class GDALFeaturePoint
36{
37 public:
42 GDALFeaturePoint();
43
48 GDALFeaturePoint(const GDALFeaturePoint &fp);
49
62 GDALFeaturePoint(int nX, int nY, int nScale, int nRadius, int nSign);
63 virtual ~GDALFeaturePoint();
64
66 GDALFeaturePoint &operator=(const GDALFeaturePoint &point);
67
78 double &operator[](int nIndex);
79
90 double operator[](int nIndex) const;
91
93 static const int DESC_SIZE = 64;
94
100 int GetX() const;
101
107 void SetX(int nX);
108
114 int GetY() const;
115
121 void SetY(int nY);
122
128 int GetScale() const;
129
135 void SetScale(int nScale);
136
142 int GetRadius() const;
143
149 void SetRadius(int nRadius);
150
156 int GetSign() const;
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 CPL_DISALLOW_COPY_ASSIGN(GDALIntegralImage)
189
190 public:
191 GDALIntegralImage();
192 virtual ~GDALIntegralImage();
193
201 void Initialize(const double **padfImg, int nHeight, int nWidth);
202
212 double GetValue(int nRow, int nCol);
213
225 double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight);
226
236 double HaarWavelet_X(int nRow, int nCol, int nSize);
237
247 double HaarWavelet_Y(int nRow, int nCol, int nSize);
248
254 int GetHeight();
255
261 int GetWidth();
262
263 private:
264 double **pMatrix = nullptr;
265 int nWidth = 0;
266 int nHeight = 0;
267};
268
278 class GDALOctaveLayer
279{
280 CPL_DISALLOW_COPY_ASSIGN(GDALOctaveLayer)
281
282 public:
283 GDALOctaveLayer();
284
293 GDALOctaveLayer(int nOctave, int nInterval);
294 virtual ~GDALOctaveLayer();
295
305 void ComputeLayer(GDALIntegralImage *poImg);
306
310 int octaveNum;
314 int filterSize;
318 int radius;
322 int scale;
326 int width;
330 int height;
334 double **detHessians;
338 int **signs;
339};
340
348 class GDALOctaveMap
349{
350 CPL_DISALLOW_COPY_ASSIGN(GDALOctaveMap)
351
352 public:
361 GDALOctaveMap(int nOctaveStart, int nOctaveEnd);
362 virtual ~GDALOctaveMap();
363
370 void ComputeMap(GDALIntegralImage *poImg);
371
391 static bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot,
392 GDALOctaveLayer *mid, GDALOctaveLayer *top,
393 double threshold);
394
398 GDALOctaveLayer ***pMap;
399
403 static const int INTERVALS = 4;
404
408 int octaveStart;
409
413 int octaveEnd;
414};
415
428 class GDALSimpleSURF
429{
430 private:
435 class MatchedPointPairInfo
436 {
437 public:
438 MatchedPointPairInfo(int nInd_1, int nInd_2, double dfDist)
439 : ind_1(nInd_1), ind_2(nInd_2), euclideanDist(dfDist)
440 {
441 }
442
443 int ind_1;
444 int ind_2;
445 double euclideanDist;
446 };
447
448 CPL_DISALLOW_COPY_ASSIGN(GDALSimpleSURF)
449
450 public:
475 GDALSimpleSURF(int nOctaveStart, int nOctaveEnd);
476 virtual ~GDALSimpleSURF();
477
494 static CPLErr ConvertRGBToLuminosity(GDALRasterBand *red,
495 GDALRasterBand *green,
496 GDALRasterBand *blue, int nXSize,
497 int nYSize, double **padfImg,
498 int nHeight, int nWidth);
499
515 std::vector<GDALFeaturePoint> *
516 ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold);
517
538 static CPLErr
539 MatchFeaturePoints(std::vector<GDALFeaturePoint *> *poMatchPairs,
540 std::vector<GDALFeaturePoint> *poFirstCollect,
541 std::vector<GDALFeaturePoint> *poSecondCollect,
542 double dfThreshold);
543
544 private:
554 static double GetEuclideanDistance(const GDALFeaturePoint &firstPoint,
555 const GDALFeaturePoint &secondPoint);
556
562 static void NormalizeDistances(std::list<MatchedPointPairInfo> *poList);
563
570 static void SetDescriptor(GDALFeaturePoint *poPoint,
571 GDALIntegralImage *poImg);
572
573 private:
574 int octaveStart;
575 int octaveEnd;
576 GDALOctaveMap *poOctMap;
577};
578
579#endif /* GDALSIMPLESURF_H_ */
GDALFeaturePoint
Class of "feature point" in raster.
Definition: gdal_simplesurf.h:36
GDALFeaturePoint::GDALFeaturePoint
GDALFeaturePoint()
Standard constructor.
Definition: gdal_simplesurf.cpp:22
GDALFeaturePoint::SetY
void SetY(int nY)
Set Y coordinate of point.
Definition: gdal_simplesurf.cpp:80
GDALFeaturePoint::operator=
GDALFeaturePoint & operator=(const GDALFeaturePoint &point)
Assignment operator.
Definition: gdal_simplesurf.cpp:43
GDALFeaturePoint::GetSign
int GetSign() const
Fetch sign of Hessian determinant of point.
Definition: gdal_simplesurf.cpp:105
GDALFeaturePoint::SetX
void SetX(int nX)
Set X coordinate of point.
Definition: gdal_simplesurf.cpp:70
GDALFeaturePoint::DESC_SIZE
static const int DESC_SIZE
Descriptor length.
Definition: gdal_simplesurf.h:93
GDALFeaturePoint::GetY
int GetY() const
Fetch Y-coordinate (line) of point.
Definition: gdal_simplesurf.cpp:75
GDALFeaturePoint::GetRadius
int GetRadius() const
Fetch radius of point.
Definition: gdal_simplesurf.cpp:95
GDALFeaturePoint::GetScale
int GetScale() const
Fetch scale of point.
Definition: gdal_simplesurf.cpp:85
GDALFeaturePoint::GetX
int GetX() const
Fetch X-coordinate (pixel) of point.
Definition: gdal_simplesurf.cpp:65
GDALFeaturePoint::SetScale
void SetScale(int nScale)
Set scale of point.
Definition: gdal_simplesurf.cpp:90
GDALFeaturePoint::SetRadius
void SetRadius(int nRadius)
Set radius of point.
Definition: gdal_simplesurf.cpp:100
GDALFeaturePoint::SetSign
void SetSign(int nSign)
Set sign of point.
Definition: gdal_simplesurf.cpp:110
GDALFeaturePoint::operator[]
double & operator[](int nIndex)
Provide access to point's descriptor.
Definition: gdal_simplesurf.cpp:115
GDALIntegralImage
Integral image class (summed area table).
Definition: gdal_simplesurf.h:187
GDALIntegralImage::GetHeight
int GetHeight()
Fetch height of integral image.
Definition: gdal_octave.cpp:22
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:127
GDALIntegralImage::GetValue
double GetValue(int nRow, int nCol)
Fetch value of specified position in integral image.
Definition: gdal_octave.cpp:74
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:121
GDALIntegralImage::Initialize
void Initialize(const double **padfImg, int nHeight, int nWidth)
Compute integral image for specified array.
Definition: gdal_octave.cpp:32
GDALIntegralImage::GetRectangleSum
double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight)
Get sum of values in specified rectangular grid.
Definition: gdal_octave.cpp:82
GDALIntegralImage::GetWidth
int GetWidth()
Fetch width of integral image.
Definition: gdal_octave.cpp:27
GDALOctaveLayer
Class for computation and storage of Hessian values in SURF-based algorithm.
Definition: gdal_simplesurf.h:279
GDALOctaveLayer::height
int height
Image height in pixels.
Definition: gdal_simplesurf.h:330
GDALOctaveLayer::signs
int ** signs
Hessian signs for speeded matching.
Definition: gdal_simplesurf.h:338
GDALOctaveLayer::detHessians
double ** detHessians
Hessian values for image pixels.
Definition: gdal_simplesurf.h:334
GDALOctaveLayer::filterSize
int filterSize
Length of the side of filter.
Definition: gdal_simplesurf.h:314
GDALOctaveLayer::radius
int radius
Length of the border.
Definition: gdal_simplesurf.h:318
GDALOctaveLayer::octaveNum
int octaveNum
Octave which contains this layer (1,2,3...)
Definition: gdal_simplesurf.h:310
GDALOctaveLayer::width
int width
Image width in pixels.
Definition: gdal_simplesurf.h:326
GDALOctaveLayer::scale
int scale
Scale for this layer.
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:156
GDALOctaveMap
Class for handling octave layers in SURF-based algorithm.
Definition: gdal_simplesurf.h:349
GDALOctaveMap::INTERVALS
static const int INTERVALS
Value for constructing internal octave space.
Definition: gdal_simplesurf.h:403
GDALOctaveMap::octaveStart
int octaveStart
Number of bottom octave.
Definition: gdal_simplesurf.h:408
GDALOctaveMap::pMap
GDALOctaveLayer *** pMap
2-dimensional array of octave layers
Definition: gdal_simplesurf.h:398
GDALOctaveMap::GDALOctaveMap
GDALOctaveMap(int nOctaveStart, int nOctaveEnd)
Create octave space.
Definition: gdal_octave.cpp:228
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:240
GDALOctaveMap::octaveEnd
int octaveEnd
Number of top octave.
Definition: gdal_simplesurf.h:413
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:247
GDALRasterBand
A single raster band (or channel).
Definition: gdal_priv.h:1519
GDALSimpleSURF
Class for searching corresponding points on images.
Definition: gdal_simplesurf.h:429
GDALSimpleSURF::ExtractFeaturePoints
std::vector< GDALFeaturePoint > * ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold)
Find feature points using specified integral image.
Definition: gdal_simplesurf.cpp:238
GDALSimpleSURF::GDALSimpleSURF
GDALSimpleSURF(int nOctaveStart, int nOctaveEnd)
Prepare class according to specified parameters.
Definition: gdal_simplesurf.cpp:148
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:369
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:156
cpl_conv.h
Various convenience functions for CPL.
CPLErr
CPLErr
Error category.
Definition: cpl_error.h:37
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:1030
gdal_priv.h
C++ GDAL entry points.