ComposerRuleValidNeighborhood.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 #ifndef __TERRALIB_RP_INTERNAL_COMPOSER_RULE_VALID_NEIGHBORHOOD_H
21 #define __TERRALIB_RP_INTERNAL_COMPOSER_RULE_VALID_NEIGHBORHOOD_H
22 
23 #include "ComposerRule.h"
24 #include "../srs/Converter.h"
25 
26 #include <memory>
27 
28 namespace te
29 {
30  namespace rp
31  {
32  /*!
33  \class ComposerRuleValidNeighborhood A basic composer rule capable of choosing the valid pixels (all bands with no no-data values).
34  \brief A basic composer rule capable of choosing the valid pixels (all bands with no no-data values).
35  \ingroup rp_optical
36  */
38  {
39  public:
40 
42 
44 
45  /*!
46  \brief Set the valid values ranges.
47  \param ranges1 Raster 1 values ranges.
48  \param ranges2 Raster 2 values ranges.
49  \note Valid values ranges for each band (first=min, second=max).
50  \note Ranges min and max are considered valid values.
51  */
53  const std::vector< std::pair< double, double > >& ranges1,
54  const std::vector< std::pair< double, double > >& ranges2 );
55 
56  /*!
57  \brief Get the valid values ranges.
58  \param ranges1 Raster 1 values ranges.
59  \param ranges2 Raster 2 values ranges.
60  */
62  std::vector< std::pair< double, double > >& ranges1,
63  std::vector< std::pair< double, double > >& ranges2 ) const;
64 
65  /*!
66  \brief Set the valid values neighbors window radius.
67  \param newRadius New radius.
68  \note All pixels within the radius must be valid for the center pixel be considered valid.
69  */
70  void setWindowRadius( const unsigned int newRadius );
71 
72  /*!
73  \brief Get the valid values neighbors window radius.
74  \return Get the valid values neighbors window radius.
75  */
76  unsigned int getWindowRadius() const;
77 
78  /*!
79  \brief Set the mimimum percentual of valid pixels considering the entire neighborhood for a center pixel to be considered valid.
80  \param newPercent New value (Range 0 -> 100).
81  */
82  void setNeiborMinValidPercent( const double newPercent );
83 
84  /*!
85  \brief Get the mimimum percentual of valid pixels considering the entire neighborhood for a center pixel to be considered valid.
86  \return Get the mimimum percentual of valid pixels considering the entire neighborhood for a center pixel to be considered valid.
87  */
88  double getNeiborMinValidPercent() const;
89 
90  protected:
91 
92  // overload
93  void getComposedValues( const double& line, const double& col,
94  double* const composedValuesPtr ) const;
95 
96  // overload
97  ComposerRule* clone() const;
98 
99  // overload
100  bool initialize(
101  const te::rst::Raster& raster1,
102  const std::vector< unsigned int >& raster1Bands,
103  const te::rst::Raster& raster2,
104  const std::vector< unsigned int >& raster2Bands,
105  te::rst::Raster& raster3,
106  const std::vector< unsigned int >& raster3Bands,
107  const te::rst::Interpolator::Method& interpMethod1,
108  const te::rst::Interpolator::Method& interpMethod2,
109  const double& noDataValue,
110  const bool forceRaster1NoDataValue,
111  const bool forceRaster2NoDataValue,
112  const std::vector< double >& pixelOffsets1,
113  const std::vector< double >& pixelScales1,
114  const std::vector< double >& pixelOffsets2,
115  const std::vector< double >& pixelScales2 );
116 
117  private :
118 
119  te::srs::Converter m_converter1; //<! Raster 1 converter.
120 
121  te::srs::Converter m_converter2; //<! Raster 2 converter.
122 
123  std::vector< double > m_raster1NoDataValues; //!< Raster 1 no-data values (on value per band).
124 
125  std::vector< double > m_raster2NoDataValues; //!< Raster 2 no-data values (on value per band).
126 
127  /*!
128  \brief Valid pixels windows radius.
129  */
130  long int m_windowRadius;
131 
132  /*!
133  \brief Maximum number of pixels in a window (center included)
134  */
136 
137  double m_neiborMinValidPercent; //>! Mimimum percentual of valid pixels considering the entire neighborhood.
138 
139  /*!
140  \brief Valid values ranges for each raster 1 band (first=min, second=max).
141  */
142  std::vector< std::pair< double, double > > m_ranges1;
143 
144  /*!
145  \brief Valid values ranges for each raster 1 band (first=min, second=max).
146  */
147  std::vector< std::pair< double, double > > m_ranges2;
148 
149  unsigned int m_NBands; //<! Rasters bands number.
150 
151  long int m_r1NRows; //<! Raster 1 rows number.
152 
153  long int m_r1NCols; //<! Raster 1 columns number.
154 
155  long int m_r2NRows; //<! Raster 2 rows number.
156 
157  long int m_r2NCols; //<! Raster 2 columns number.
158 
159  // variables used by getComposedValues method
168  mutable long int m_getComposedValues_row;
169  mutable long int m_getComposedValues_col;
170  mutable unsigned int m_getComposedValues_bandIdx;
181 
183 
185 
186  void initState();
187 
188  void clear();
189 
190  };
191 
192  } // end namespace rp
193 } // end namespace te
194 
195 #endif
196 
te::rp::ComposerRuleValidNeighborhood::ComposerRuleValidNeighborhood
ComposerRuleValidNeighborhood()
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_colBound
long int m_getComposedValues_colBound
Definition: ComposerRuleValidNeighborhood.h:178
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerCol2
long int m_getComposedValues_centerCol2
Definition: ComposerRuleValidNeighborhood.h:174
te::rp::ComposerRuleValidNeighborhood::initState
void initState()
te::rp::ComposerRuleValidNeighborhood::m_r1NRows
long int m_r1NRows
Definition: ComposerRuleValidNeighborhood.h:151
ComposerRule.h
te::rp::ComposerRuleValidNeighborhood::ComposerRuleValidNeighborhood
ComposerRuleValidNeighborhood(const ComposerRuleValidNeighborhood &other)
te::rp::ComposerRuleValidNeighborhood::m_neiborMinValidPercent
double m_neiborMinValidPercent
Definition: ComposerRuleValidNeighborhood.h:137
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_bandIdx
unsigned int m_getComposedValues_bandIdx
Definition: ComposerRuleValidNeighborhood.h:170
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rp::ComposerRuleValidNeighborhood::m_raster2NoDataValues
std::vector< double > m_raster2NoDataValues
Raster 2 no-data values (on value per band).
Definition: ComposerRuleValidNeighborhood.h:125
te::rp::ComposerRuleValidNeighborhood::clear
void clear()
te::rp::ComposerRuleValidNeighborhood::~ComposerRuleValidNeighborhood
~ComposerRuleValidNeighborhood()
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerCol
double m_getComposedValues_centerCol
Definition: ComposerRuleValidNeighborhood.h:164
te::rp::ComposerRuleValidNeighborhood::getComposedValues
void getComposedValues(const double &line, const double &col, double *const composedValuesPtr) const
Compose a pixel value using the current parameters.
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_pixelValue
double m_getComposedValues_pixelValue
Definition: ComposerRuleValidNeighborhood.h:180
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerX
double m_getComposedValues_centerX
Definition: ComposerRuleValidNeighborhood.h:162
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_col
long int m_getComposedValues_col
Definition: ComposerRuleValidNeighborhood.h:169
te::rp::ComposerRuleValidNeighborhood::m_r2NRows
long int m_r2NRows
Definition: ComposerRuleValidNeighborhood.h:155
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_startCol
long int m_getComposedValues_startCol
Definition: ComposerRuleValidNeighborhood.h:176
te::rp::ComposerRuleValidNeighborhood::m_raster1NoDataValues
std::vector< double > m_raster1NoDataValues
Raster 1 no-data values (on value per band).
Definition: ComposerRuleValidNeighborhood.h:123
te::rp::ComposerRuleValidNeighborhood::getValidValuesRanges
void getValidValuesRanges(std::vector< std::pair< double, double > > &ranges1, std::vector< std::pair< double, double > > &ranges2) const
Get the valid values ranges.
te::rp::ComposerRuleValidNeighborhood::m_converter1
te::srs::Converter m_converter1
Definition: ComposerRuleValidNeighborhood.h:119
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_startRow
long int m_getComposedValues_startRow
Definition: ComposerRuleValidNeighborhood.h:175
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerRow2
long int m_getComposedValues_centerRow2
Definition: ComposerRuleValidNeighborhood.h:173
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerCol1
long int m_getComposedValues_centerCol1
Definition: ComposerRuleValidNeighborhood.h:172
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_r1PixelQuality
unsigned int m_getComposedValues_r1PixelQuality
Definition: ComposerRuleValidNeighborhood.h:166
te::rp::ComposerRuleValidNeighborhood::getWindowRadius
unsigned int getWindowRadius() const
Get the valid values neighbors window radius.
te::srs::Converter
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:54
te::rp::ComposerRuleValidNeighborhood::m_ranges2
std::vector< std::pair< double, double > > m_ranges2
Valid values ranges for each raster 1 band (first=min, second=max).
Definition: ComposerRuleValidNeighborhood.h:147
te::rp::ComposerRuleValidNeighborhood::getNeiborMinValidPercent
double getNeiborMinValidPercent() const
Get the mimimum percentual of valid pixels considering the entire neighborhood for a center pixel to ...
TERPEXPORT
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerRow1
long int m_getComposedValues_centerRow1
Definition: ComposerRuleValidNeighborhood.h:171
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_row
long int m_getComposedValues_row
Definition: ComposerRuleValidNeighborhood.h:168
te::rp::ComposerRuleValidNeighborhood::m_NBands
unsigned int m_NBands
Definition: ComposerRuleValidNeighborhood.h:149
te::rp::ComposerRuleValidNeighborhood::m_r1NCols
long int m_r1NCols
Definition: ComposerRuleValidNeighborhood.h:153
te::rp::ComposerRuleValidNeighborhood::m_windowRadius
long int m_windowRadius
Valid pixels windows radius.
Definition: ComposerRuleValidNeighborhood.h:130
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerY
double m_getComposedValues_centerY
Definition: ComposerRuleValidNeighborhood.h:163
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_rowBound
long int m_getComposedValues_rowBound
Definition: ComposerRuleValidNeighborhood.h:177
te::rp::ComposerRuleValidNeighborhood::m_converter2
te::srs::Converter m_converter2
Definition: ComposerRuleValidNeighborhood.h:121
te::rp::ComposerRule
Definition: ComposerRule.h:44
te::rp::ComposerRuleValidNeighborhood::m_r2NCols
long int m_r2NCols
Definition: ComposerRuleValidNeighborhood.h:157
te::rp::ComposerRuleValidNeighborhood::operator=
const ComposerRuleValidNeighborhood & operator=(const ComposerRuleValidNeighborhood &other)
te::rp::ComposerRuleValidNeighborhood::setWindowRadius
void setWindowRadius(const unsigned int newRadius)
Set the valid values neighbors window radius.
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerX3
double m_getComposedValues_centerX3
Definition: ComposerRuleValidNeighborhood.h:160
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerRow
double m_getComposedValues_centerRow
Definition: ComposerRuleValidNeighborhood.h:165
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_r2PixelQuality
unsigned int m_getComposedValues_r2PixelQuality
Definition: ComposerRuleValidNeighborhood.h:167
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_pixelIsValid
bool m_getComposedValues_pixelIsValid
Definition: ComposerRuleValidNeighborhood.h:179
te::rp::ComposerRuleValidNeighborhood::m_ranges1
std::vector< std::pair< double, double > > m_ranges1
Valid values ranges for each raster 1 band (first=min, second=max).
Definition: ComposerRuleValidNeighborhood.h:142
te::rp::ComposerRuleValidNeighborhood
A basic composer rule capable of choosing the valid pixels (all bands with no no-data values).
Definition: ComposerRuleValidNeighborhood.h:38
te::rp::ComposerRuleValidNeighborhood::clone
ComposerRule * clone() const
Create a clone of this instance.
te::rp::ComposerRuleValidNeighborhood::m_windowMaxNPixels
long int m_windowMaxNPixels
Maximum number of pixels in a window (center included)
Definition: ComposerRuleValidNeighborhood.h:135
te::rp::ComposerRuleValidNeighborhood::setNeiborMinValidPercent
void setNeiborMinValidPercent(const double newPercent)
Set the mimimum percentual of valid pixels considering the entire neighborhood for a center pixel to ...
te::rp::ComposerRuleValidNeighborhood::m_getComposedValues_centerY3
double m_getComposedValues_centerY3
Definition: ComposerRuleValidNeighborhood.h:161
te::rp::ComposerRuleValidNeighborhood::setValidValuesRanges
void setValidValuesRanges(const std::vector< std::pair< double, double > > &ranges1, const std::vector< std::pair< double, double > > &ranges2)
Set the valid values ranges.
te::rp::ComposerRuleValidNeighborhood::initialize
bool initialize(const te::rst::Raster &raster1, const std::vector< unsigned int > &raster1Bands, const te::rst::Raster &raster2, const std::vector< unsigned int > &raster2Bands, te::rst::Raster &raster3, const std::vector< unsigned int > &raster3Bands, const te::rst::Interpolator::Method &interpMethod1, const te::rst::Interpolator::Method &interpMethod2, const double &noDataValue, const bool forceRaster1NoDataValue, const bool forceRaster2NoDataValue, const std::vector< double > &pixelOffsets1, const std::vector< double > &pixelScales1, const std::vector< double > &pixelOffsets2, const std::vector< double > &pixelScales2)
Inititate the instance.