- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# gdal_simplesurf.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * Project:  GDAL
    00003  * Purpose:  Correlator
    00004  * Author:   Andrew Migal, migal.drew@gmail.com
    00005  *
    00006  ******************************************************************************
    00007  * Copyright (c) 2012, Andrew Migal
    00008  *
    00009  * Permission is hereby granted, free of charge, to any person obtaining a
    00010  * copy of this software and associated documentation files (the "Software"),
    00011  * to deal in the Software without restriction, including without limitation
    00012  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00013  * and/or sell copies of the Software, and to permit persons to whom the
    00014  * Software is furnished to do so, subject to the following conditions:
    00015  *
    00016  * The above copyright notice and this permission notice shall be included
    00017  * in all copies or substantial portions of the Software.
    00018  *
    00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00020  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    00022  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    00025  * DEALINGS IN THE SOFTWARE.
    00026  ****************************************************************************/
    00027
    00034 #ifndef GDALSIMPLESURF_H_
    00035 #define GDALSIMPLESURF_H_
    00036
    00037 #include "gdal_priv.h"
    00038 #include "cpl_conv.h"
    00039 #include <list>
    00040
    00049 class GDALFeaturePoint
    00050 {
    00051 public:
    00056     GDALFeaturePoint();
    00057
    00062     GDALFeaturePoint(const GDALFeaturePoint& fp);
    00063
    00076     GDALFeaturePoint(int nX, int nY, int nScale, int nRadius, int nSign);
    00077     virtual ~GDALFeaturePoint();
    00078
    00079     GDALFeaturePoint& operator=(const GDALFeaturePoint& point);
    00080
    00090     double& operator[](int nIndex);
    00091
    00092     // Descriptor length
    00093     static const int DESC_SIZE = 64;
    00094
    00100     int GetX();
    00101
    00107     void SetX(int nX);
    00108
    00114     int  GetY();
    00115
    00121     void SetY(int nY);
    00122
    00128     int  GetScale();
    00129
    00135     void SetScale(int nScale);
    00136
    00142     int  GetRadius();
    00143
    00149     void SetRadius(int nRadius);
    00150
    00156     int  GetSign();
    00157
    00163     void SetSign(int nSign);
    00164
    00165 private:
    00166     // Coordinates of point in image
    00167     int nX;
    00168     int nY;
    00169     // --------------------
    00170     int nScale;
    00171     int nRadius;
    00172     int nSign;
    00173     // Descriptor array
    00174     double *padfDescriptor;
    00175 };
    00176
    00186 class GDALIntegralImage
    00187 {
    00188 public:
    00189     GDALIntegralImage();
    00190     virtual ~GDALIntegralImage();
    00191
    00199     void Initialize(const double **padfImg, int nHeight, int nWidth);
    00200
    00209     double GetValue(int nRow, int nCol);
    00210
    00222     double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight);
    00223
    00233     double HaarWavelet_X(int nRow, int nCol, int nSize);
    00234
    00244     double HaarWavelet_Y(int nRow, int nCol, int nSize);
    00245
    00251     int GetHeight();
    00252
    00258     int GetWidth();
    00259
    00260 private:
    00261     double **pMatrix;
    00262     int nWidth;
    00263     int nHeight;
    00264 };
    00265
    00274 class GDALOctaveLayer
    00275 {
    00276 public:
    00277     GDALOctaveLayer();
    00278
    00287     GDALOctaveLayer(int nOctave, int nInterval);
    00288     virtual ~GDALOctaveLayer();
    00289
    00299     void ComputeLayer(GDALIntegralImage *poImg);
    00300
    00304     int octaveNum;
    00308     int filterSize;
    00312     int radius;
    00316     int scale;
    00320     int width;
    00324     int height;
    00328     double **detHessians;
    00332     int **signs;
    00333 };
    00334
    00341 class GDALOctaveMap
    00342 {
    00343 public:
    00350     GDALOctaveMap(int nOctaveStart, int nOctaveEnd);
    00351     virtual ~GDALOctaveMap();
    00352
    00359     void ComputeMap(GDALIntegralImage *poImg);
    00360
    00378     bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot,
    00379                          GDALOctaveLayer *mid, GDALOctaveLayer *top, double threshold);
    00380
    00384     GDALOctaveLayer ***pMap;
    00385
    00389     static const int INTERVALS = 4;
    00390
    00394     int octaveStart;
    00395
    00399     int octaveEnd;
    00400 };
    00401
    00413 class GDALSimpleSURF
    00414 {
    00415 private:
    00420     class MatchedPointPairInfo
    00421     {
    00422     public:
    00423         MatchedPointPairInfo(int nInd_1, int nInd_2, double dfDist)
    00424             {
    00425                 ind_1 = nInd_1;
    00426                 ind_2 = nInd_2;
    00427                 euclideanDist = dfDist;
    00428             }
    00429
    00430         int ind_1;
    00431         int ind_2;
    00432         double euclideanDist;
    00433     };
    00434
    00435 public:
    00457     GDALSimpleSURF(int nOctaveStart, int nOctaveEnd);
    00458     virtual ~GDALSimpleSURF();
    00459
    00476     static CPLErr ConvertRGBToLuminosity(
    00477         GDALRasterBand *red,
    00478         GDALRasterBand *green,
    00479         GDALRasterBand *blue,
    00480         int nXSize, int nYSize,
    00481         double **padfImg, int nHeight, int nWidth);
    00482
    00497     std::vector<GDALFeaturePoint>*
    00498     ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold);
    00499
    00512     static CPLErr MatchFeaturePoints(
    00513         std::vector<GDALFeaturePoint*> *poMatchPairs,
    00514         std::vector<GDALFeaturePoint> *poFirstCollect,
    00515         std::vector<GDALFeaturePoint> *poSecondCollect,
    00516         double dfThreshold);
    00517
    00518 private:
    00528     static double GetEuclideanDistance(
    00529         GDALFeaturePoint &firstPoint, GDALFeaturePoint &secondPoint);
    00530
    00536     static void NormalizeDistances(std::list<MatchedPointPairInfo> *poList);
    00537
    00544     void SetDescriptor(GDALFeaturePoint *poPoint, GDALIntegralImage *poImg);
    00545
    00546
    00547 private:
    00548     int octaveStart;
    00549     int octaveEnd;
    00550     GDALOctaveMap *poOctMap;
    00551 };
    00552
    00553
    00554 #endif /* GDALSIMPLESURF_H_ */

Generated for GDAL by 1.7.1.