All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TiePointsLocatorMoravecStrategy.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/rp/TiePointsLocatorMoravecStrategy.h
22  \brief Tie-Pointsr locator Moravec strategy.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_TIEPOINTSLOCATORMORAVECSTRATEGY_H
26 #define __TERRALIB_RP_INTERNAL_TIEPOINTSLOCATORMORAVECSTRATEGY_H
27 
29 #include "../geometry/GeometricTransformation.h"
30 
31 #include <vector>
32 
33 #include <boost/thread.hpp>
34 
35 namespace te
36 {
37  namespace rp
38  {
39  // Forwards
40  class TiePointsLocator;
41 
42  /*!
43  \class TiePointsLocatorMoravecStrategy
44  \brief Tie-points locator Moravec strategy.
45  */
47  {
48  friend class TiePointsLocator;
49 
50  public:
51 
53 
54  protected :
55 
56  /*!
57  \brief The parameters passed to the moravecLocatorThreadEntry method.
58  */
60  {
61  public :
62 
63  bool* m_returnValuePtr; //! Thread return value pointer.
64 
65  unsigned int m_moravecWindowWidth; //!< The Moravec window width used to locate canditate tie-points (minimum 11, default: 11 ).
66 
67  FloatsMatrix const* m_rasterDataPtr; //!< The loaded raster data.
68 
69  UCharsMatrix const* m_maskRasterDataPtr; //!< The loaded mask raster data pointer (or zero if no mask is avaliable).
70 
71  std::vector< InterestPointsSetT >* m_interestPointsSubSectorsPtr; //!< A pointer to a valid interest points container (one element by subsector)..
72 
73  unsigned int m_maxInterestPointsBySubSector; //!< The maximum number of interest points by sub-sector.
74 
75  unsigned int m_tiePointsSubSectorsSplitFactor; //!< The number of sectors along each direction.
76 
77  boost::mutex* m_rastaDataAccessMutexPtr; //!< A pointer to a valid mutex to controle raster data access.
78 
79  boost::mutex* m_interestPointsAccessMutexPtr; //!< A pointer to a valid mutex to control the output interest points container access.
80 
81  unsigned int m_processingBlocksNumber; //!< The raster data will be splitted into this number of blocks for processing.
82 
83  unsigned int* m_nextRasterLinesBlockToProcessValuePtr; //!< A pointer to a valid counter to control the blocks processing sequence.
84 
86 
88  };
89 
90  /*!
91  \brief The parameters passed to the matchCorrelationEuclideanThreadEntry method.
92  */
94  {
95  public :
96 
98 
100 
102 
104 
106 
108 
109  boost::mutex* m_syncMutexPtr;
110 
111  te::gm::GeometricTransformation const * m_raster1ToRaster2TransfPtr; //!< A pointer to a transformation direct mapping raster 1 indexed coords into raster 2 indexed coords, of an empty pointer if there is no transformation avaliable.
112 
113  double m_searchOptTreeSearchRadius; //!< Optimization tree search radius (pixels).
114 
116 
118  };
119 
120  bool m_isInitialized; //!< true if this instance is initialized.
121 
123 
125 
126  //overload
127  bool initialize(
128  const te::rp::TiePointsLocatorInputParameters& inputParameters );
129 
130  //overload
131  void reset();
132 
133  //overload
134  bool getMatchedInterestPoints(
135  te::gm::GeometricTransformation const * const raster1ToRaster2TransfPtr,
136  const double raster1ToRaster2TransfDMapError,
137  MatchedInterestPointsSetT& matchedInterestPoints );
138 
139  //overload
140  unsigned int getAutoMaxTiePointsNumber() const;
141 
142  /*!
143  \brief Mean Filter.
144 
145  \param inputData The input data.
146 
147  \param outputData The output data.
148 
149  \param iterationsNumber The number of filter iterations.
150 
151  \return true if ok, false on errors.
152  */
153  static bool applyMeanFilter(
154  const FloatsMatrix& inputData,
155  FloatsMatrix& outputData,
156  const unsigned int iterationsNumber );
157 
158  /*!
159  \brief Moravec interest points locator.
160 
161  \param maxInterestPoints The maximum number of interest points to find.
162 
163  \param rasterData The loaded raster data.
164 
165  \param maskRasterDataPtr The loaded mask raster data pointer (or zero if no mask is avaliable).
166 
167  \param interestPoints The found interest points (coords related to rasterData lines/cols).
168 
169  \note InterestPointT::m_feature1 will be sum of differences between the Moravec filter response of each pixel and its neighborhoods (always a positive value).
170 
171  \return true if ok, false on errors.
172  */
173  bool locateMoravecInterestPoints(
174  const unsigned int maxInterestPoints,
175  const FloatsMatrix& rasterData,
176  UCharsMatrix const* maskRasterDataPtr,
177  InterestPointsSetT& interestPoints ) const;
178 
179  /*!
180  \brief Movavec locator thread entry.
181 
182  \param paramsPtr A pointer to the thread parameters.
183  */
184  static void locateMoravecInterestPointsThreadEntry(MoravecLocatorThreadParams* paramsPtr);
185 
186  /*!
187  \brief Generate correlation features ( normalized - unit vector ) matrix for the given interes points.
188 
189  \param interestPoints The interest points (coords related to rasterData lines/cols).
190 
191  \param correlationWindowWidth The correlation window width used to correlate points between the images.
192 
193  \param rasterData The loaded raster data.
194 
195  \param features The generated features matrix (one feature per line, one feature per interes point).
196 
197  \param validInteresPoints The valid interest pionts related to each feature inside the features matrix (some interest points may be invalid and are removed).
198 
199  \return true if ok, false on errors.
200  */
201  static bool generateCorrelationFeatures(
202  const InterestPointsSetT& interestPoints,
203  const unsigned int correlationWindowWidth,
204  const FloatsMatrix& rasterData,
205  FloatsMatrix& features,
206  InterestPointsSetT& validInteresPoints );
207 
208  /*!
209  \brief Match each feature using correlation.
210 
211  \param featuresSet1 Features set 1.
212 
213  \param featuresSet2 Features set 2.
214 
215  \param interestPointsSet1 The interest pionts set 1 (full raster 1 indexed coods reference).
216 
217  \param interestPointsSet2 The interest pionts set 2 (full raster 1 indexed coods reference).
218 
219  \param raster1ToRaster2TransfPtr A pointer to a transformation direct mapping raster 1 indexed coords into raster 2 indexed coords, of an empty pointer if there is no transformation avaliable.
220 
221  \param raster1ToRaster2TransfDMapError The expected transformation error.
222 
223  \param matchedPoints The matched points (full raster 1 indexed coods reference).
224 
225  \note Each matched point feature value ( MatchedInterestPoint::m_feature ) will be set to the absolute value of the correlation between then.
226  */
227  bool executeMatchingByCorrelation(
228  const FloatsMatrix& featuresSet1,
229  const FloatsMatrix& featuresSet2,
230  const InterestPointsSetT& interestPointsSet1,
231  const InterestPointsSetT& interestPointsSet2,
232  te::gm::GeometricTransformation const * const raster1ToRaster2TransfPtr,
233  const double raster1ToRaster2TransfDMapError,
234  MatchedInterestPointsSetT& matchedPoints ) const;
235 
236  /*!
237  \brief Correlation/Euclidean match thread entry.
238 
239  \param paramsPtr A pointer to the thread parameters.
240  */
241  static void executeMatchingByCorrelationThreadEntry(
243  };
244 
245  } // end namespace rp
246 } // end namespace te
247 
248 #endif
249 
te::rp::TiePointsLocatorInputParameters m_inputParameters
Input parameters.
std::vector< InterestPointsSetT > * m_interestPointsSubSectorsPtr
A pointer to a valid interest points container (one element by subsector)..
2D Geometric transformation base class.
Tie-Pointsr locator strategy.
te::gm::GeometricTransformation const * m_raster1ToRaster2TransfPtr
A pointer to a transformation direct mapping raster 1 indexed coords into raster 2 indexed coords...
unsigned int m_processingBlocksNumber
The raster data will be splitted into this number of blocks for processing.
std::multiset< InterestPointT > InterestPointsSetT
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:141
bool m_isInitialized
true if this instance is initialized.
unsigned int m_maxInterestPointsBySubSector
The maximum number of interest points by sub-sector.
The parameters passed to the matchCorrelationEuclideanThreadEntry method.
Tie-points locator strategy.
Tie points locator.
The parameters passed to the moravecLocatorThreadEntry method.
unsigned int m_tiePointsSubSectorsSplitFactor
The number of sectors along each direction.
A generic template matrix.
Definition: Matrix.h:51
boost::mutex * m_interestPointsAccessMutexPtr
A pointer to a valid mutex to control the output interest points container access.
UCharsMatrix const * m_maskRasterDataPtr
The loaded mask raster data pointer (or zero if no mask is avaliable).
unsigned int * m_nextRasterLinesBlockToProcessValuePtr
A pointer to a valid counter to control the blocks processing sequence.
std::multiset< MatchedInterestPointsT > MatchedInterestPointsSetT
boost::mutex * m_rastaDataAccessMutexPtr
A pointer to a valid mutex to controle raster data access.