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 
30 #include "SegmenterSegmentsBlock.h"
31 
32 #include "Config.h"
33 
34 #include <vector>
35 
36 namespace te
37 {
38  namespace rp
39  {
40  /*!
41  \class SegmenterRegionGrowingBaatzMerger
42  \brief Baatz based Segments merger
43  */
45  public SegmenterRegionGrowingMerger< rg::BaatzFeatureType >
46  {
47  public:
48  /*!
49  \brief Default constructor.
50  \param bandsWeights A reference to an external valid structure where each bands weight are stored.
51  \param segmentsIds //!< A reference to an external valid structure where all segments IDs are stored.
52  \param segmentsMatrix //!< A reference to an external valid segments matrix.
53  \param colorWeight //!< The weight given to the color component, deafult:0.5, valid range: [0,1].
54  \param compactnessWeight //!< The weight given to the compactness component, deafult:0.5, valid range: [0,1].
55  */
56  SegmenterRegionGrowingBaatzMerger( const double& colorWeight,
57  const double& compactnessWeight,
58  const std::vector< double >& bandsWeights,
59  const SegmentsIdsMatrixT& segmentsIds );
60 
62 
63  //overload
65  getDissimilarity( SegmenterRegionGrowingSegment< rg::BaatzFeatureType > const * const segment1Ptr,
67  SegmenterRegionGrowingSegment< rg::BaatzFeatureType > * const mergePreviewSegPtr ) const;
68 
69  //overload
70  void mergeFeatures( SegmenterRegionGrowingSegment< rg::BaatzFeatureType > * const segment1Ptr,
72  SegmenterRegionGrowingSegment< rg::BaatzFeatureType > const * const mergePreviewSegPtr ) const;
73 
74  //overload
75  void update( SegmenterRegionGrowingSegment< rg::BaatzFeatureType >* const actSegsListHeadPtr );
76 
77  //overload
78  inline unsigned int getSegmentFeaturesSize() const { return 3 + ( 3 * m_bandsNumber ); };
79 
80  protected :
81  const SegmentsIdsMatrixT& m_segmentsIds; //!< A reference to an external valid structure where each all segments IDs are stored.
82 
83  unsigned int m_bandsNumber; //!< The number of features (bands).
84 
85  rg::BaatzFeatureType m_allSegsCompactnessOffset; //!< The offsets applied to normalize the compactness value.
86  rg::BaatzFeatureType m_allSegsCompactnessGain; //!< The gains applied to normalize the compactness value.
87  rg::BaatzFeatureType m_allSegsSmoothnessOffset; //!< The offsets applied to normalize the smoothness value.
88  rg::BaatzFeatureType m_allSegsSmoothnessGain; //!< The gains applied to normalize the smoothness value.
89  rg::BaatzFeatureType m_allSegsStdDevOffset; //!< The offsets applied to normalize the standard deviation value.
90  rg::BaatzFeatureType m_allSegsStdDevGain; //!< The gains applied to normalize the standard deviation value.
91  rg::BaatzFeatureType m_colorWeight; //!< The weight given to the color component, deafult:0.5, valid range: [0,1].
92  rg::BaatzFeatureType m_compactnessWeight; //!< The weight given to the compactness component, deafult:0.5, valid range: [0,1].
93  std::vector< rg::BaatzFeatureType > m_bandsWeights; //!< A vector where each bands weight are stored.
94 
95  // Variables used by the method getDissimilarity
109  mutable unsigned int m_getDissimilarity_sumsIdx;
110 
111  // Variables used by the method update
120  mutable unsigned int m_update_band;
122 
123  /*!
124  \brief Returns the count of points from region 1 (with ID1) touching the region 2 (with ID2).
125  \param segsIds The segment ids container.
126  \param xStart The upper left X of the bounding box surrounding both regions.
127  \param yStart The upper left Y of the bounding box surrounding both regions.
128  \param xBound The lower right X bound of the bounding box surrounding both regions.
129  \param yBound The lower right Y bound of the bounding box surrounding both regions.
130  \param id1 Region 1 ID.
131  \param id2 Region 2 ID.
132  \param edgeLength1 The touching edge length for the region 1.
133  \param edgeLength2 The touching edge length for the region 2.
134  \return Returns the count of points from region 1 (with ID1) touching the region 2 (with ID2).
135  */
136  static void getTouchingEdgeLength( const SegmentsIdsMatrixT& segsIds,
137  const unsigned int& xStart, const unsigned int& yStart,
138  const unsigned int& xBound, const unsigned int& yBound,
141  unsigned int& edgeLength1,
142  unsigned int& edgeLength2 );
143  };
144  } // end namespace rp
145 } // end namespace te
146 
147 #endif // __TERRALIB_RP_INTERNAL_SEGMENTERREGIONGROWINGBAATZMERGER_H
std::vector< rg::BaatzFeatureType > m_bandsWeights
A vector where each bands weight are stored.
double DissimilarityTypeT
Type for dissimilarity.
rg::BaatzFeatureType m_colorWeight
The weight given to the color component, deafult:0.5, valid range: [0,1].
float BaatzFeatureType
Baatz Strategy feature type.
rg::BaatzFeatureType m_allSegsStdDevGain
The gains applied to normalize the standard deviation value.
Segmenter merger used in region growing process.
rg::BaatzFeatureType m_compactnessWeight
The weight given to the compactness component, deafult:0.5, valid range: [0,1].
rg::BaatzFeatureType m_allSegsSmoothnessGain
The gains applied to normalize the smoothness value.
SegmenterRegionGrowingSegment< rg::BaatzFeatureType > * m_update_currentActSegPtr
rg::BaatzFeatureType m_allSegsStdDevOffset
The offsets applied to normalize the standard deviation value.
URI C++ Library.
Abstract class for the segments merger.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
rg::BaatzFeatureType m_allSegsCompactnessGain
The gains applied to normalize the compactness value.
unsigned int m_bandsNumber
The number of features (bands).
Configuration flags for the Raster Processing module of TerraLib.
Segments block.
rg::BaatzFeatureType m_allSegsCompactnessOffset
The offsets applied to normalize the compactness value.
rg::BaatzFeatureType m_allSegsSmoothnessOffset
The offsets applied to normalize the smoothness value.