All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RasterAttributes.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/RasterAttributes.h
22 
23  \brief Extraction of attributes from Raster, Bands, and Polygons.
24  */
25 
26 #ifndef __TERRALIB_RP_INTERNAL_RASTERATTRIBUTES_H
27 #define __TERRALIB_RP_INTERNAL_RASTERATTRIBUTES_H
28 
29 // TerraLib
30 #include "../statistics/core/NumericStatisticalSummary.h"
31 #include "Algorithm.h"
32 #include "Config.h"
33 #include "Exception.h"
34 #include "Texture.h"
35 
36 // Boost
37 #include <boost/numeric/ublas/io.hpp>
38 #include <boost/numeric/ublas/matrix.hpp>
39 
40 // STL
41 #include <complex>
42 
43 namespace te
44 {
45 // Forward declaration
46  namespace gm
47  {
48  class Polygon;
49  }
50  namespace rst
51  {
52  class Band;
53  class Raster;
54  }
55 
56  namespace rp
57  {
58  /*!
59  \class RasterAttributes
60 
61  \brief Extraction of attributes from Raster, Bands, and Polygons.
62  */
64  {
65  public:
66 
67  /*! \brief Public constructor. */
69 
71 
72  // overload
73  bool initialize(const AlgorithmInputParameters& inputParams) throw(te::rp::Exception);
74 
75  //overload
76  bool isInitialized() const;
77 
78  // overload
79  bool execute(AlgorithmOutputParameters& outputParams) throw(te::rp::Exception);
80 
81  // overload
82  void reset() throw(te::rp::Exception);
83 
84  /*!
85  \brief Returns the pixel values (real and imag) for the band, inside the polygon.
86 
87  \param raster The input raster.
88  \param band The position of the input band.
89  \param polygon The input polygon.
90 
91  \return The pixel values for the band, inside the polygon.
92 
93  \warning Band and polygon must fit.
94  */
95  std::vector<std::complex<double> > getComplexValuesFromBand(const te::rst::Raster& raster, unsigned int band, const te::gm::Polygon& polygon);
96 
97  /*!
98  \brief Returns the pixel values for the band, inside the polygon.
99 
100  \param raster The input raster.
101  \param band The position of the input band.
102  \param polygon The input polygon.
103 
104  \return The pixel values for the band, inside the polygon.
105 
106  \warning Band and polygon must fit.
107  */
108  std::vector<double> getValuesFromBand(const te::rst::Raster& raster, unsigned int band, const te::gm::Polygon& polygon);
109 
110  /*!
111  \brief Returns the pixel values (real and imag) for all the bands in raster, inside the polygon.
112 
113  \param raster The input band.
114  \param polygon The input polygon.
115  \param bands Bands to be processed from the input raster.
116 
117  \return A vector with the pixel values for all the bands in raster, inside the polygon, with values[band][pixel].
118 
119  \warning Bands and polygon must fit.
120  */
121  std::vector<std::vector<std::complex<double> > > getComplexValuesFromRaster(const te::rst::Raster& raster, const te::gm::Polygon& polygon, std::vector<unsigned int> bands);
122 
123  /*!
124  \brief Returns the pixel values for all the bands in raster, inside the polygon.
125 
126  \param raster The input band.
127  \param polygon The input polygon.
128  \param bands Bands to be processed from the input raster.
129 
130  \return A vector with the pixel values for all the bands in raster, inside the polygon, with values[band][pixel].
131 
132  \warning Bands and polygon must fit.
133  */
134  std::vector<std::vector<double> > getValuesFromRaster(const te::rst::Raster& raster, const te::gm::Polygon& polygon, std::vector<unsigned int> bands);
135 
136  /*!
137  \brief Returns several statistics from a set of pixels.
138 
139  \param pixels A vector of pixel values.
140 
141  \return A series of statistics (\sa te::stat::NumericStatisticalSummary).
142  */
143  te::stat::NumericStatisticalSummary getStatistics(std::vector<double>& pixels);
144 
145  /*!
146  \brief Returns the covariance matrix between vectors of pixel values.
147 
148  \param vpixels The vector of pixel vectors, with vpixels[band][pixel].
149  \param vmeans The vector of pixels means, one mean per vector of pixels.
150 
151  \return The covariance matrix between the vectors of pixel values.
152 
153  \warning All vectors sizes must fit.
154  */
155  boost::numeric::ublas::matrix<double> getCovarianceMatrix(const std::vector<std::vector<double> >& vpixels, const std::vector<double>& vmeans);
156 
157  /*!
158  \brief Computes the Gray-Level CoOccurrence Matrix (GLCM) from a raster band.
159 
160  \param rin The input raster.
161  \param band The input band position.
162  \param dx The displacement in x direction, to be considered as neighborhood, can be either + or -.
163  \param dy The displacement in y direction, to be considered as neighborhood, can be either + or -.
164 
165  \return The GLCM from the raster band.
166 
167  \warning The pixels from the input band will be considered of type unsigned int.
168  */
169  boost::numeric::ublas::matrix<double> getGLCM(const te::rst::Raster& rin, unsigned int band, int dx, int dy);
170 
171  /*!
172  \brief Computes the Gray-Level CoOccurrence Matrix (GLCM) from a raster band, inside the polygon.
173 
174  \param rin The input raster.
175  \param band The input band position.
176  \param dx The displacement in x direction, to be considered as neighborhood, can be either + or -.
177  \param dy The displacement in y direction, to be considered as neighborhood, can be either + or -.
178  \param polygon The input polygon.
179 
180  \return The GLCM from the raster band, inside the polygon.
181 
182  \warning The pixels from the input band will be considered of type unsigned int.
183  */
184  boost::numeric::ublas::matrix<double> getGLCM(const te::rst::Raster& rin, unsigned int band, int dx, int dy, const te::gm::Polygon& polygon);
185 
186  /*!
187  \brief Compute texture metrics from GLCM matrix.
188 
189  \param glcm The input GLCM matrix.
190 
191  \return The Texture structure will all available metrics computed.
192  */
193  te::rp::Texture getGLCMMetrics(boost::numeric::ublas::matrix<double> glcm);
194 
195  };
196 
197  } // end namespace rp
198 } // end namespace te
199 
200 #endif // __TERRALIB_RP_INTERNAL_RASTERATTRIBUTES_H
A structure to hold the set of statistics from a set of numerical values.
A structure to hold the set of GLCM metrics.
Raster Processing algorithm output parameters base interface.
Extraction of attributes from Raster, Bands, and Polygons.
Exception class.
Raster Processing algorithm base interface.
Definition: Algorithm.h:41
An abstract class for raster data strucutures.
Definition: Raster.h:71
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:141
Raster Processing algorithm base interface class.
Configuration flags for the Raster Processing module of TerraLib.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
A structure to hold the set of GLCM metrics.
Definition: Texture.h:44
Raster Processing algorithm input parameters base interface.