SegmenterStrategy.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/SegmenterStrategy.h
22  \brief Raster segmenter strategy base class.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_SEGMENTERSTRATEGY_H
26 #define __TERRALIB_RP_INTERNAL_SEGMENTERSTRATEGY_H
27 
28 #include "SegmenterIdsManager.h"
30 #include "SegmenterSegmentsBlock.h"
31 #include "Config.h"
32 #include "Exception.h"
33 
34 #include "../raster/Raster.h"
35 
36 #include <vector>
37 
38 namespace te
39 {
40  namespace rp
41  {
42  /*!
43  \class SegmenterStrategy
44  \brief Raster segmenter strategy base class.
45  */
47  {
48  public:
49  /*!
50  \brief Blocks merging method.
51  */
53  {
54  NoMerging = 0, //!< No merging.
55  GradientMerging = 1 //!< Gradient Merging.
56  };
57 
58  virtual ~SegmenterStrategy();
59 
60  /*!
61  \brief Initialize the segmentation strategy.
62  \param strategyParams A pointer to the user given specific segmentation
63  strategy parameters ou NULL if no parameters are present.
64  \return true if OK, false on errors.
65  */
66  virtual bool initialize(
67  SegmenterStrategyParameters const* const strategyParams )
68  throw( te::rp::Exception ) = 0;
69 
70  /*!
71  \brief Clear all internal allocated resources and go back to the initial not-initialized state.
72  */
73  virtual void reset() = 0;
74 
75  /*!
76  \brief Executes the segmentation strategy over region delimited by the given block.
77  \param segmenterIdsManager The segments IDs manager to be used when acquiring/releaseing unique segment IDs.
78  \param block2ProcessInfo The information about the block of raster that must be processed.
79  \param inputRaster Input raster.
80  \param inputRasterBands Input raster bands.
81  \param inputRasterNoDataValues A vector of values to be used as input raster no-data values.
82  \param inputRasterBandMinValues The minimum value present on each band.
83  \param inputRasterBandMinValues The maximum value present on each band.
84  \param outputRaster Output raster.
85  \param outputRasterBand Output raster band.
86  \param enableProgressInterface Enable the internal strategy to update
87  the progress interface.
88  \return true if OK, false on errors.
89  \note The used gaind/ofset calcule: new_value = ( old_value + offset ) * gain
90  */
91  virtual bool execute(
92  SegmenterIdsManager& segmenterIdsManager,
93  const te::rp::SegmenterSegmentsBlock& block2ProcessInfo,
94  const te::rst::Raster& inputRaster,
95  const std::vector< unsigned int >& inputRasterBands,
96  const std::vector< std::complex< double > >& inputRasterNoDataValues,
97  const std::vector< std::complex< double > >& inputRasterBandMinValues,
98  const std::vector< std::complex< double > >& inputRasterBandMaxValues,
99  te::rst::Raster& outputRaster,
100  const unsigned int outputRasterBand,
101  const bool enableProgressInterface ) throw( te::rp::Exception ) = 0;
102 
103  /*!
104  \brief Returns a memory estimation (bytes).
105  \details This parameter is used by the segmenter to guess the sub-image blocks size.
106  \param bandsToProcess The number of input raster bands that will be processed at the strategy execution time.
107  \param pixelsNumber The number of pixels.
108  \return A positive memory use estimation.
109  */
110  virtual double getMemUsageEstimation( const unsigned int bandsToProcess,
111  const unsigned int pixelsNumber ) const = 0;
112 
113  /*!
114  \brief Returns a optimal blocks overlap size (number of border pixels
115  overlapped between blocks, under one direction).
116  \note This value will be used in the case
117  where the image is splitted into blocks for segmentation.
118  \return The blocks overlap size.
119  */
120  virtual unsigned int getOptimalBlocksOverlapSize() const = 0;
121 
122  /*!
123  \brief Returns if the min and max pixel values should be computed.
124  \return True if min and max values should be computed. False otherwise.
125  */
126  virtual bool shouldComputeMinMaxValues() const = 0;
127 
128  /*!
129  \brief Return the strategy blocks merging method.
130  \return The blocks merging method.
131  */
132  virtual BlocksMergingMethod getBlocksMergingMethod() const = 0;
133 
134  protected:
135 
137 
138  private:
139 
141 
142  const SegmenterStrategy& operator=( const SegmenterStrategy& );
143  };
144 
145  } // end namespace rp
146 } // end namespace te
147 
148 #endif // __TERRALIB_RP_INTERNAL_ALGORITHM_H
149 
Segmenter segments IDs manager.
Exception class.
Segments IDs manager.
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
Raster segmenter strategy base class.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
Configuration flags for the Raster Processing module of TerraLib.
Segments block.
Raster segmenter strategy parameters base class.
BlocksMergingMethod
Blocks merging method.
Segmenter segments block description class.