All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GTFilter.h
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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/geometry/GTFilter.h
22 
23  \brief 2D Geometric transformation outliers remotion filter.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_GTFILTER_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_GTFILTER_H
28 
29 // TerraLib
30 #include "Config.h"
31 #include "GTParameters.h"
33 
34 // STL
35 #include <map>
36 #include <memory>
37 #include <vector>
38 
39 // Boost
40 #include <boost/noncopyable.hpp>
41 #include <boost/thread.hpp>
42 
43 namespace te
44 {
45  namespace gm
46  {
47  /*!
48  \class GTFilter
49 
50  \brief 2D Geometric transformation tie-points filter (outliers remotion).
51  */
52  class TEGEOMEXPORT GTFilter : boost::noncopyable
53  {
54  public:
55 
56  /*! \brief RANSAC iterations counter type. */
57  typedef unsigned long long int RansacItCounterT;
58 
59  /*! \brief Default constructor. */
60  GTFilter();
61 
62  /*! \brief Destructor. */
63  ~GTFilter();
64 
65  /*!
66  \brief Apply a RANSAC based outliers remotion strategy.
67 
68  \param transfName Transformation name (see te::gm::GTFactory dictionary for reference).
69  \param inputParams Input transformation parameters.
70  \param maxDirectMapError The maximum allowed direct mapping error.
71  \param maxInverseMapError The maximum allowed inverse mapping error.
72  \param maxIterations The maximum number of iterations (Use 0-zero to let this number be automatically found).
73  \param assurance The error-free selection assurance - valid range (0-1) - Use Lower values for good tie-points sets - Higher values may increase the number of iterations.
74  \param enableMultiThread Enable multi-threaded processing (good for multi-processor or multi-core systems).
75  \param outTransf The generated output transformation (with the base mininum required tie-points set).
76  \param tiePointsWeights Optional tie-points weights (only positive values) or an empty vector if no weights must be used.
77  \param outTiePoints The filtered output tie-points (non-outliers) in agreenment with the generated transformation.
78 
79  \return true if OK, false on errors.
80 
81  \note Reference: Martin A. Fischler and Robert C. Bolles, Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography, Communications of the ACM archive, Volume 24, Issue 6 (June 1981).
82  */
83  bool applyRansac(const std::string& transfName,
84  const GTParameters& inputParams,
85  const double maxDirectMapError,
86  const double maxInverseMapError,
87  const RansacItCounterT& maxIterations,
88  const double& assurance,
89  const bool enableMultiThread,
90  const std::vector< double >& tiePointsWeights,
91  std::vector< te::gm::GTParameters::TiePoint >& outTiePoints,
92  std::auto_ptr< GeometricTransformation >& outTransf
93  );
94 
95  private:
96 
97  /*!
98  \class ApplyRansacThreadEntryThreadParams
99 
100  \brief Parameters used by the GTFilter::applyRansacThreadEntry method.
101  */
103  {
104  public:
105 
106  std::string const* m_transfNamePtr;
110  double m_assurance;
115  boost::mutex* m_mutexPtr;
117  std::map< double, GTParameters::TiePoint > const* m_tpsMapPtr; //!< A map from accumulated probabilities (normalized between 0 and 1) to tie-points data.
118  std::auto_ptr< GeometricTransformation >* m_bestTransformationPtrPtr;
122  std::vector< te::gm::GTParameters::TiePoint >* m_bestTiePoinsPtr;
123 
125 
127 
129 
130  const ApplyRansacThreadEntryThreadParams& operator=(
131  const ApplyRansacThreadEntryThreadParams& other );
132  };
133 
134  /*!
135  \brief Returns the tie-points convex hull area (GTParameters::TiePoint::first).
136 
137  \param tiePoints Tie points.
138 
139  \return The tie-points convex hull area
140  */
141  static double getPt1ConvexHullArea(const std::vector<GTParameters::TiePoint>& tiePoints);
142 
143  /*!
144  \brief Surf locator thread entry.
145 
146  \param paramsPtr A pointer to the thread parameters.
147  */
148  static void applyRansacThreadEntry(te::gm::GTFilter::ApplyRansacThreadEntryThreadParams* paramsPtr);
149 
150  };
151 
152  } // end namespace gm
153 } // end namespace te
154 
155 #endif // __TERRALIB_GEOMETRY_INTERNAL_GTFILTER_H
156 
2D Geometric transformation base class.
2D Geometric transformation parameters.
unsigned long long int RansacItCounterT
RANSAC iterations counter type.
Definition: GTFilter.h:57
std::map< double, GTParameters::TiePoint > const * m_tpsMapPtr
A map from accumulated probabilities (normalized between 0 and 1) to tie-points data.
Definition: GTFilter.h:117
2D Geometric transformation tie-points filter (outliers remotion).
Definition: GTFilter.h:52
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:79
std::vector< te::gm::GTParameters::TiePoint > * m_bestTiePoinsPtr
Definition: GTFilter.h:122
Parameters used by the GTFilter::applyRansacThreadEntry method.
Definition: GTFilter.h:102
std::auto_ptr< GeometricTransformation > * m_bestTransformationPtrPtr
Definition: GTFilter.h:118
2D Geometric transformation parameters.
Definition: GTParameters.h:50
Configuration flags for the Vector Geometry Model of TerraLib.