|
GDAL
|
00001 /****************************************************************************** 00002 * $Id: gdal_simplesurf.h 36666 2016-12-04 04:32:31Z goatbar $ 00003 * Project: GDAL 00004 * Purpose: Correlator 00005 * Author: Andrew Migal, migal.drew@gmail.com 00006 * 00007 ****************************************************************************** 00008 * Copyright (c) 2012, Andrew Migal 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining a 00011 * copy of this software and associated documentation files (the "Software"), 00012 * to deal in the Software without restriction, including without limitation 00013 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00014 * and/or sell copies of the Software, and to permit persons to whom the 00015 * Software is furnished to do so, subject to the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be included 00018 * in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00021 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00023 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00025 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00026 * DEALINGS IN THE SOFTWARE. 00027 ****************************************************************************/ 00028 00035 #ifndef GDALSIMPLESURF_H_ 00036 #define GDALSIMPLESURF_H_ 00037 00038 #include "gdal_priv.h" 00039 #include "cpl_conv.h" 00040 #include <list> 00041 00050 class GDALFeaturePoint 00051 { 00052 public: 00057 GDALFeaturePoint(); 00058 00063 GDALFeaturePoint(const GDALFeaturePoint& fp); 00064 00077 GDALFeaturePoint(int nX, int nY, int nScale, int nRadius, int nSign); 00078 virtual ~GDALFeaturePoint(); 00079 00081 GDALFeaturePoint& operator=(const GDALFeaturePoint& point); 00082 00092 double& operator[](int nIndex); 00093 00095 static const int DESC_SIZE = 64; 00096 00102 int GetX() const; 00103 00109 void SetX(int nX); 00110 00116 int GetY() const; 00117 00123 void SetY(int nY); 00124 00130 int GetScale() const ; 00131 00137 void SetScale(int nScale); 00138 00144 int GetRadius() const; 00145 00151 void SetRadius(int nRadius); 00152 00158 int GetSign() const; 00159 00165 void SetSign(int nSign); 00166 00167 private: 00168 // Coordinates of point in image 00169 int nX; 00170 int nY; 00171 // -------------------- 00172 int nScale; 00173 int nRadius; 00174 int nSign; 00175 // Descriptor array 00176 double *padfDescriptor; 00177 }; 00178 00188 class GDALIntegralImage 00189 { 00190 public: 00191 GDALIntegralImage(); 00192 virtual ~GDALIntegralImage(); 00193 00201 void Initialize(const double **padfImg, int nHeight, int nWidth); 00202 00211 double GetValue(int nRow, int nCol); 00212 00224 double GetRectangleSum(int nRow, int nCol, int nWidth, int nHeight); 00225 00235 double HaarWavelet_X(int nRow, int nCol, int nSize); 00236 00246 double HaarWavelet_Y(int nRow, int nCol, int nSize); 00247 00253 int GetHeight(); 00254 00260 int GetWidth(); 00261 00262 private: 00263 double **pMatrix; 00264 int nWidth; 00265 int nHeight; 00266 }; 00267 00276 class GDALOctaveLayer 00277 { 00278 public: 00279 GDALOctaveLayer(); 00280 00289 GDALOctaveLayer(int nOctave, int nInterval); 00290 virtual ~GDALOctaveLayer(); 00291 00301 void ComputeLayer(GDALIntegralImage *poImg); 00302 00306 int octaveNum; 00310 int filterSize; 00314 int radius; 00318 int scale; 00322 int width; 00326 int height; 00330 double **detHessians; 00334 int **signs; 00335 }; 00336 00343 class GDALOctaveMap 00344 { 00345 CPL_DISALLOW_COPY_ASSIGN( GDALOctaveMap ) 00346 00347 public: 00354 GDALOctaveMap(int nOctaveStart, int nOctaveEnd); 00355 virtual ~GDALOctaveMap(); 00356 00363 void ComputeMap(GDALIntegralImage *poImg); 00364 00382 static bool PointIsExtremum(int row, int col, GDALOctaveLayer *bot, 00383 GDALOctaveLayer *mid, GDALOctaveLayer *top, double threshold); 00384 00388 GDALOctaveLayer ***pMap; 00389 00393 static const int INTERVALS = 4; 00394 00398 int octaveStart; 00399 00403 int octaveEnd; 00404 }; 00405 00417 class GDALSimpleSURF 00418 { 00419 private: 00424 class MatchedPointPairInfo 00425 { 00426 public: 00427 MatchedPointPairInfo(int nInd_1, int nInd_2, double dfDist) 00428 { 00429 ind_1 = nInd_1; 00430 ind_2 = nInd_2; 00431 euclideanDist = dfDist; 00432 } 00433 00434 int ind_1; 00435 int ind_2; 00436 double euclideanDist; 00437 }; 00438 00439 CPL_DISALLOW_COPY_ASSIGN( GDALSimpleSURF ) 00440 00441 public: 00463 GDALSimpleSURF(int nOctaveStart, int nOctaveEnd); 00464 virtual ~GDALSimpleSURF(); 00465 00482 static CPLErr ConvertRGBToLuminosity( 00483 GDALRasterBand *red, 00484 GDALRasterBand *green, 00485 GDALRasterBand *blue, 00486 int nXSize, int nYSize, 00487 double **padfImg, int nHeight, int nWidth); 00488 00503 std::vector<GDALFeaturePoint>* 00504 ExtractFeaturePoints(GDALIntegralImage *poImg, double dfThreshold); 00505 00518 static CPLErr MatchFeaturePoints( 00519 std::vector<GDALFeaturePoint*> *poMatchPairs, 00520 std::vector<GDALFeaturePoint> *poFirstCollect, 00521 std::vector<GDALFeaturePoint> *poSecondCollect, 00522 double dfThreshold); 00523 00524 private: 00534 static double GetEuclideanDistance( 00535 GDALFeaturePoint &firstPoint, GDALFeaturePoint &secondPoint); 00536 00542 static void NormalizeDistances(std::list<MatchedPointPairInfo> *poList); 00543 00550 static void SetDescriptor(GDALFeaturePoint *poPoint, GDALIntegralImage *poImg); 00551 00552 private: 00553 int octaveStart; 00554 int octaveEnd; 00555 GDALOctaveMap *poOctMap; 00556 }; 00557 00558 #endif /* GDALSIMPLESURF_H_ */
1.7.6.1.