Loading...
Searching...
No Matches
SegmenterRegionGrowingBaatzMerger.h
Go to the documentation of this file.
1/* Copyright (C) 2015 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/SegmenterRegionGrowingBaatzMerger.h
22 \brief Segmenter Baatz merger used in region growing process.
23*/
24
25#ifndef __TERRALIB_RP_INTERNAL_SEGMENTERREGIONGROWINGBAATZMERGER_H
26#define __TERRALIB_RP_INTERNAL_SEGMENTERREGIONGROWINGBAATZMERGER_H
27
32
33#include "Config.h"
34
35#include <vector>
36
37namespace te
38{
39 namespace rp
40 {
41 /*!
42 \class SegmenterRegionGrowingBaatzMerger
43 \brief Baatz based Segments merger
44 */
46 public SegmenterRegionGrowingMerger< rg::BaatzFeatureType >
47 {
48 public:
49 /*!
50 \brief Default constructor.
51 \param bandsWeights A reference to an external valid structure where each bands weight are stored.
52 \param segmentsIds //!< A reference to an external valid structure where all segments IDs are stored.
53 \param segmentsMatrix //!< A reference to an external valid segments matrix.
54 \param colorWeight //!< The weight given to the color component, deafult:0.5, valid range: [0,1].
55 \param compactnessWeight //!< The weight given to the compactness component, deafult:0.5, valid range: [0,1].
56 */
57 SegmenterRegionGrowingBaatzMerger( const double& colorWeight,
58 const double& compactnessWeight,
59 const std::vector< double >& bandsWeights,
60 const SegmentsIdsMatrixT& segmentsIds );
61
63
64 //overload
68 SegmenterRegionGrowingMergeData * const mergeDataPtr ) const;
69
70 //overload
73 SegmenterRegionGrowingMergeData const * const mergeDataPtr ) const;
74
75 //overload
77
78 //overload
79 inline unsigned int getSegmentFeaturesSize() const { return m_segmentFeaturesSize; };
80
82
83 protected :
84 /*!
85 \class MergeData
86 \brief Baatz specific merge data.
87 */
89 {
90 public:
91
92 MergeData( const unsigned int featuresNumber );
93
95
96 /*!
97 \brief Vctor of segment features (this class will take the ownership and delete[] at destruction time).
98 */
100
101 private:
102
103 MergeData( const MergeData& other ) {};
104 const MergeData& operator=( const MergeData& other ) { return *this; };
105 };
106
107 mutable int* m_dirsColOffsVecPtr; //!< pointer to a internal vector of directions column offsets.
108 mutable int* m_dirsRowOffsVecPtr; //!< pointer to a internal vector of directions row offsets.
109 const SegmentsIdsMatrixT& m_segmentsIdsMatrix; //!< A reference to an external valid structure where each all segments IDs are stored.
110 unsigned int m_segmentsIdsMatrixNRows; //!< Matrix rows numnber;
111 unsigned int m_segmentsIdsMatrixNCols; //!< Matrix cols numnber;
112 unsigned int m_bandsNumber; //!< The number of features (bands).
113 unsigned int m_segmentFeaturesSize; //< the required segments features vector size (numer of elements).
114 rg::BaatzFeatureType m_allSegsCompactnessOffset; //!< The offsets applied to normalize the compactness value.
115 rg::BaatzFeatureType m_allSegsCompactnessGain; //!< The gains applied to normalize the compactness value.
116 rg::BaatzFeatureType m_allSegsSmoothnessOffset; //!< The offsets applied to normalize the smoothness value.
117 rg::BaatzFeatureType m_allSegsSmoothnessGain; //!< The gains applied to normalize the smoothness value.
118 rg::BaatzFeatureType m_allSegsStdDevOffset; //!< The offsets applied to normalize the standard deviation value.
119 rg::BaatzFeatureType m_allSegsStdDevGain; //!< The gains applied to normalize the standard deviation value.
120 rg::BaatzFeatureType m_colorWeight; //!< The weight given to the color component, deafult:0.5, valid range: [0,1].
121 rg::BaatzFeatureType m_compactnessWeight; //!< The weight given to the compactness component, deafult:0.5, valid range: [0,1].
122 std::vector< rg::BaatzFeatureType > m_bandsWeights; //!< A vector where each bands weight are stored.
123
124 // Variables used by the method getDissimilarity
138 mutable unsigned int m_getDissimilarity_sumsIdx;
141
142 //Variables used by the method mergeFeaturs
144
145 // Variables used by the method update
154 unsigned int m_update_band;
156
157 // Variables used by getTouchingEdgeLength
162
163
164 /*!
165 \brief Returns the count of points from region 1 (with ID1) touching the region 2 (with ID2).
166 \param colStart1 The upper left X of the bounding box surrounding region 1.
167 \param rowStart1 The upper left Y of the bounding box surrounding region 1.
168 \param colBound1 The lower right X bound of the bounding box surrounding region 1.
169 \param rowBound1 The lower right Y bound of the bounding box surrounding region 1.
170 \param colStart2 The upper left X of the bounding box surrounding region 2.
171 \param rowStart2 The upper left Y of the bounding box surrounding region 2.
172 \param colBound2 The lower right X bound of the bounding box surrounding region 2.
173 \param rowBound2 The lower right Y bound of the bounding box surrounding region 21.
174 \param id1 Region 1 ID.
175 \param id2 Region 2 ID.
176 \param touchingEdgeLength The touching edge length.
177 \note The internal m_segmentsIdsMatrix will be used.
178 */
180 const unsigned int& colStart1,
181 const unsigned int& rowStart1,
182 const unsigned int& colBound1,
183 const unsigned int& rowBound1,
184 const unsigned int& colStart2,
185 const unsigned int& rowStart2,
186 const unsigned int& colBound2,
187 const unsigned int& rowBound2,
190 unsigned int& touchingEdgeLength ) const;
191 };
192 } // end namespace rp
193} // end namespace te
194
195#endif // __TERRALIB_RP_INTERNAL_SEGMENTERREGIONGROWINGBAATZMERGER_H
Segmenter data used by the merger (region growing process).
Segmenter merger used in region growing process.
MergeData(const unsigned int featuresNumber)
rg::BaatzFeatureType * m_features
Vctor of segment features (this class will take the ownership and delete[] at destruction time).
rg::BaatzFeatureType m_allSegsStdDevOffset
The offsets applied to normalize the standard deviation value.
rg::BaatzFeatureType m_allSegsStdDevGain
The gains applied to normalize the standard deviation value.
const SegmentsIdsMatrixT & m_segmentsIdsMatrix
A reference to an external valid structure where each all segments IDs are stored.
rg::BaatzFeatureType m_allSegsSmoothnessOffset
The offsets applied to normalize the smoothness value.
int * m_dirsColOffsVecPtr
pointer to a internal vector of directions column offsets.
rg::BaatzFeatureType m_compactnessWeight
The weight given to the compactness component, deafult:0.5, valid range: [0,1].
DissimilarityTypeT getDissimilarity(SegmenterRegionGrowingSegment< rg::BaatzFeatureType > const *const segment1Ptr, SegmenterRegionGrowingSegment< rg::BaatzFeatureType > const *const segment2Ptr, SegmenterRegionGrowingMergeData *const mergeDataPtr) const
Returns a dimilarity index between this and the other segment.
rg::BaatzFeatureType m_allSegsCompactnessGain
The gains applied to normalize the compactness value.
void update(SegmenterRegionGrowingSegment< rg::BaatzFeatureType > *const actSegsListHeadPtr)
Update the internal state.
unsigned int m_bandsNumber
The number of features (bands).
rg::BaatzFeatureType m_allSegsSmoothnessGain
The gains applied to normalize the smoothness value.
std::vector< rg::BaatzFeatureType > m_bandsWeights
A vector where each bands weight are stored.
unsigned int getSegmentFeaturesSize() const
Return the required segments features vector size (numer of elements).
void createMergeData(SegmenterRegionGrowingMergeData **mergeDataPtr) const
Create a new merge data instance when applicable.
SegmenterRegionGrowingBaatzMerger(const double &colorWeight, const double &compactnessWeight, const std::vector< double > &bandsWeights, const SegmentsIdsMatrixT &segmentsIds)
Default constructor.
rg::BaatzFeatureType m_allSegsCompactnessOffset
The offsets applied to normalize the compactness value.
rg::BaatzFeatureType m_colorWeight
The weight given to the color component, deafult:0.5, valid range: [0,1].
void getTouchingEdgeLength(const unsigned int &colStart1, const unsigned int &rowStart1, const unsigned int &colBound1, const unsigned int &rowBound1, const unsigned int &colStart2, const unsigned int &rowStart2, const unsigned int &colBound2, const unsigned int &rowBound2, const SegmenterSegmentsBlock::SegmentIdDataType &id1, const SegmenterSegmentsBlock::SegmentIdDataType &id2, unsigned int &touchingEdgeLength) const
Returns the count of points from region 1 (with ID1) touching the region 2 (with ID2).
int * m_dirsRowOffsVecPtr
pointer to a internal vector of directions row offsets.
void mergeFeatures(SegmenterRegionGrowingSegment< rg::BaatzFeatureType > *const segment1Ptr, SegmenterRegionGrowingSegment< rg::BaatzFeatureType > const *const segment2Ptr, SegmenterRegionGrowingMergeData const *const mergeDataPtr) const
Merge specific segment features from both segments into the first segment.
SegmenterRegionGrowingSegment< rg::BaatzFeatureType > * m_update_currentActSegPtr
Segmenter data used by the merger in region growing process.
Abstract class for the segments merger.
float BaatzFeatureType
Baatz Strategy feature type.
double DissimilarityTypeT
Type for dissimilarity.
TerraLib.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
Proxy configuration file for TerraView (see terraview_config.h).