Loading...
Searching...
No Matches
GTFilter.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/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#include <thread>
39#include <mutex>
40
41namespace te
42{
43 namespace gm
44 {
45 /*!
46 \class GTFilter
47
48 \brief 2D Geometric transformation tie-points filter (outliers remotion).
49 */
51 {
52 public:
53
54 /*! \brief RANSAC integer counter type. */
55 typedef unsigned long int RansacIntegerCounterT;
56
57 /*! \brief RANSAC floating point counter type. */
58 typedef long double RansacFloatCounterT;
59
60 /*!
61 \enum RansacAreaRestrictionType
62 \brief Spatial relations between geometric objects.
63 */
65 {
66 RANSAC_NO_AREA_REST = 0, /*!< No area restriction. */
67 RANSAC_BBOX_AREA_REST = 1, /*!< Preference will be given to tie-points groups with bigger bounding-box areas. */
68 RANSAC_CHULL_AREA_REST = 2 /*!< Preference will be given to tie-points groups with bigger convex hull areas. */
69 };
70
71 /*! \brief Default constructor. */
73
74 /*! \brief Destructor. */
76
77 /*!
78 \brief Apply a RANSAC based outliers remotion strategy.
79
80 \param transfName Transformation name (see te::gm::GTFactory dictionary for reference).
81 \param inputParams Input transformation parameters.
82 \param allowedMaxDirectMapError The maximum allowed direct mapping error.
83 \param allowedMaxInverseMapError The maximum allowed inverse mapping error.
84 \param maxIterations The maximum number of iterations (Use 0-zero to let this number be automatically found).
85 \param enableMultiThread Enable multi-threaded processing (good for multi-processor or multi-core systems).
86 \param outTransf The generated output transformation (with the base mininum required tie-points set).
87 \param tiePointsWeights Optional tie-points weights (only positive values) or an empty vector if no weights must be used.
88 \param outTiePoints The filtered output tie-points (non-outliers) in agreenment with the generated transformation.
89 \param areaRestT RANSAC area restriction type.
90
91 \return true if OK, false on errors.
92
93 \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).
94 */
95 bool applyRansac(const std::string& transfName,
96 const GTParameters& inputParams,
97 const double allowedMaxDirectMapError,
98 const double allowedMaxInverseMapError,
99 const RansacIntegerCounterT& maxIterations,
100 const bool enableMultiThread,
101 const RANSACAreaRestrictionType areaRestT,
102 const std::vector< double >& tiePointsWeights,
103 std::vector< te::gm::GTParameters::TiePoint >& outTiePoints,
104 std::unique_ptr< GeometricTransformation >& outTransf
105 );
106
107 protected:
108
109 /*!
110 \class RansacSetData
111
112 \brief Parameters used by the GTFilter::applyRansacThreadEntry method.
113 */
115 {
116 public:
117
120 double m_area1;
121 double m_area2;
123 std::vector< te::gm::GTParameters::TiePoint > m_tiePoins;
124
127 };
128
129 /*!
130 \class ApplyRansacThreadEntryThreadParams
131
132 \brief Parameters used by the GTFilter::applyRansacThreadEntry method.
133 */
135 {
136 public:
137
138 std::string m_transfName;
148 std::mutex* m_mutexPtr;
150 std::map< double, GTParameters::TiePoint > const* m_tpsMapPtr; //!< A map from accumulated probabilities (normalized between 0 and 1) to tie-points data.
158
160
162
163 private :
164
166
169 };
170
171 /*!
172 \brief Returns the tie-points convex hull area.
173 \param area1 GTParameters::TiePoint::first area.
174 \param area2 GTParameters::TiePoint::second area.
175 \param tiePoints Tie points.
176 */
178 const std::vector<GTParameters::TiePoint>& tiePoints,
179 double& area1, double& area2 );
180
181 /*!
182 \brief Surf locator thread entry.
183
184 \param paramsPtr A pointer to the thread parameters.
185 */
187
188 /*!
189 \brief Returns the number of expected iterations to be performed.
190 \param goodTPNumber Number of good tie-points.
191 \param totalTPNumber Total number of tie-points.
192 \param modelRequiredTPNumber Model minimum required tie-points.
193 \return The number of expected iterations to be performed.
194 */
196 const unsigned int goodTPNumber,
197 const unsigned int totalTPNumber,
198 const unsigned int modelRequiredTPNumber );
199
200 };
201
202 } // end namespace gm
203} // end namespace te
204
205#endif // __TERRALIB_GEOMETRY_INTERNAL_GTFILTER_H
206
2D Geometric transformation parameters.
2D Geometric transformation base class.
Parameters used by the GTFilter::applyRansacThreadEntry method.
Definition: GTFilter.h:135
ApplyRansacThreadEntryThreadParams(const ApplyRansacThreadEntryThreadParams &other)
RansacIntegerCounterT * m_globalIterationsCounterPtr
Definition: GTFilter.h:155
RansacIntegerCounterT * m_dynamicMaxConsInvalidIterationsPtr
Definition: GTFilter.h:145
RansacIntegerCounterT * m_globalConsInvalidIterationsCounterPtr
Definition: GTFilter.h:157
RansacIntegerCounterT * m_dynamicMaxConsLowQualityIterationsPtr
Definition: GTFilter.h:144
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:150
RansacIntegerCounterT * m_globalConsecutiveLowQualitySetsCounterPtr
Definition: GTFilter.h:156
const ApplyRansacThreadEntryThreadParams & operator=(const ApplyRansacThreadEntryThreadParams &other)
Parameters used by the GTFilter::applyRansacThreadEntry method.
Definition: GTFilter.h:115
std::vector< te::gm::GTParameters::TiePoint > m_tiePoins
Definition: GTFilter.h:123
GTParameters m_transformationParams
Definition: GTFilter.h:122
2D Geometric transformation tie-points filter (outliers remotion).
Definition: GTFilter.h:51
static void applyRansacThreadEntry(te::gm::GTFilter::ApplyRansacThreadEntryThreadParams *paramsPtr)
Surf locator thread entry.
static RansacIntegerCounterT getExcpectedIterationsNumber(const unsigned int goodTPNumber, const unsigned int totalTPNumber, const unsigned int modelRequiredTPNumber)
Returns the number of expected iterations to be performed.
bool applyRansac(const std::string &transfName, const GTParameters &inputParams, const double allowedMaxDirectMapError, const double allowedMaxInverseMapError, const RansacIntegerCounterT &maxIterations, const bool enableMultiThread, const RANSACAreaRestrictionType areaRestT, const std::vector< double > &tiePointsWeights, std::vector< te::gm::GTParameters::TiePoint > &outTiePoints, std::unique_ptr< GeometricTransformation > &outTransf)
Apply a RANSAC based outliers remotion strategy.
unsigned long int RansacIntegerCounterT
RANSAC integer counter type.
Definition: GTFilter.h:55
GTFilter()
Default constructor.
static void getTPsConvexHullArea(const std::vector< GTParameters::TiePoint > &tiePoints, double &area1, double &area2)
Returns the tie-points convex hull area.
~GTFilter()
Destructor.
long double RansacFloatCounterT
RANSAC floating point counter type.
Definition: GTFilter.h:58
2D Geometric transformation parameters.
Definition: GTParameters.h:51
TerraLib.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
Proxy configuration file for TerraView (see terraview_config.h).