Functions.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/Functions.h
22  \brief Raster Processing functions.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_FUNCTIONS_H
26 #define __TERRALIB_RP_INTERNAL_FUNCTIONS_H
27 
28 #include "Config.h"
29 
30 #include "FeedersRaster.h"
31 #include "Matrix.h"
32 #include "Macros.h"
33 #include "RasterHandler.h"
34 #include "../dataaccess/datasource/DataSource.h"
35 #include "../raster/Raster.h"
36 #include "../raster/RasterFactory.h"
37 #include "../raster/Grid.h"
38 #include "../raster/BandProperty.h"
39 #include "../raster/RasterFactory.h"
40 #include "../raster/Interpolator.h"
41 #include "../raster/Utils.h"
42 #include "../raster/PositionIterator.h"
43 #include "../srs/Converter.h"
44 #include "../geometry/LinearRing.h"
45 #include "../geometry/GTParameters.h"
46 #include "../geometry/MultiPoint.h"
47 #include "../geometry/Surface.h"
48 
49 // STL
50 #include <memory>
51 #include <map>
52 #include <vector>
53 #include <string>
54 #include <limits>
55 
56 // Boost
57 #include <boost/numeric/ublas/matrix.hpp>
58 #include <boost/shared_ptr.hpp>
59 
60 namespace te
61 {
62  namespace rst
63  {
64  class BandProperty;
65  class Grid;
66  }
67 
68  namespace rp
69  {
70  /*!
71  \brief Wavelet Atrous Filter types.
72  \ingroup rp_func
73  */
75  {
76  InvalidWAFilter, //!< Invalid filter type
77  B3SplineWAFilter, //!< Spline filter type.
78  TriangleWAFilter //!< Triangle filter type.
79  };
80 
82  {
84 
85  SpectralSensorParams(const int &band, const double &lower, const double &upper, const double &min, const double &max) :
86  m_band(band),
87  m_lower(lower),
88  m_upper(upper),
89  m_min(min),
90  m_max(max)
91  {}
92 
93  int m_band;
94  double m_lower;
95  double m_upper;
96  double m_min;
97  double m_max;
98  };
99 
100  /*!
101  \brief Create a new raster into the givem data source.
102  \param rasterGrid The template grid used to create the output raster.
103  \param bandsProperties The template band properties used to create the output raster.
104  \param outDataSetName The data set name to give to the created data set.
105  \param dataSourceType The data source type string (i.e. GDAL, MEM.)( See te::rst::RasterFactory dictionary for valid registered values ).
106  \param outRasterHandler The created raster handler.
107  \return true if OK, false on errors.
108  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
109  \ingroup rp_func
110  */
111  bool TERPEXPORT CreateNewRaster( const te::rst::Grid& rasterGrid,
112  const std::vector< te::rst::BandProperty* >& bandsProperties,
113  const std::string& outDataSetName,
114  const std::string& dataSourceType,
115  RasterHandler& outRasterHandler );
116 
117  /*!
118  \brief Create a new raster into the givem data source.
119  \param rasterGrid The template grid used to create the output raster.
120  \param bandsProperties The template band properties used to create the output raster.
121  \param outDataSetName The data set name to give to the created data set.
122  \param outDataSource The data source to use when creating the output data set.
123  \param outRasterHandler The created raster handler.
124  \return true if OK, false on errors.
125  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
126  \ingroup rp_func
127  */
128  bool TERPEXPORT CreateNewRaster( const te::rst::Grid& rasterGrid,
129  const std::vector< te::rst::BandProperty* >& bandsProperties,
130  const std::string& outDataSetName,
131  te::da::DataSource& outDataSource,
132  RasterHandler& outRasterHandler );
133 
134  /*!
135  \brief Create a new raster into the givem data source.
136  \param rasterGrid The template grid used to create the output raster.
137  \param bandsProperties The template band properties used to create the output raster.
138  \param rasterInfo The output raster info (specific driver info).
139  \param rasterType The output raster type (specific driver name - See te::rst::RasterFactory dictorary for more info).
140  \param outRasterPtr The created raster pointer.
141  \return true if OK, false on errors.
142  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
143  \ingroup rp_func
144  */
145  bool TERPEXPORT CreateNewRaster( const te::rst::Grid& rasterGrid,
146  const std::vector< te::rst::BandProperty* >& bandsProperties,
147  const std::map< std::string, std::string>& rasterInfo,
148  const std::string& rasterType,
149  std::unique_ptr< te::rst::Raster >& outRasterPtr );
150 
151  /*!
152  \brief Create a new raster into a new memory datasource.
153  \param rasterGrid The template grid used to create the output raster.
154  \param bandsProperties The template band properties used to create the output raster.
155  \param outRasterHandler The created raster handler.
156  \return true if OK, false on errors.
157  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
158  \ingroup rp_func
159  */
160  bool TERPEXPORT CreateNewMemRaster( const te::rst::Grid& rasterGrid,
161  std::vector< te::rst::BandProperty* > bandsProperties,
162  RasterHandler& outRasterHandler );
163 
164  /*!
165  \brief Create a new raster into a GDAL datasource.
166  \param rasterGrid The template grid used to create the output raster.
167  \param bandsProperties The template band properties used to create the output raster.
168  \param fileName The output tif file name.
169  \param outRasterHandler The created raster handler.
170  \return true if OK, false on errors.
171  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
172  \ingroup rp_func
173  */
175  std::vector< te::rst::BandProperty* > bandsProperties,
176  const std::string& fileName,
177  RasterHandler& outRasterHandler );
178 
179  /*!
180  \brief Create a new raster into a GDAL datasource.
181  \param rasterGrid The template grid used to create the output raster.
182  \param bandsProperties The template band properties used to create the output raster.
183  \param fileName The output tif file name.
184  \param outRasterPtr The created raster pointer.
185  \return true if OK, false on errors.
186  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
187  \ingroup rp_func
188  */
190  std::vector< te::rst::BandProperty* > bandsProperties,
191  const std::string& fileName,
192  std::unique_ptr< te::rst::Raster >& outRasterPtr );
193 
194  /*!
195  \brief Create a new raster into a GDAL datasource.
196  \param rasterGrid The template grid used to create the output raster.
197  \param bandsProperties The template band properties used to create the output raster.
198  \param fileName The output tif file name.
199  \param outRasterHandler The created raster handler.
200  \return true if OK, false on errors.
201  \note All bandsProperties pointed objects will be acquired by this function and must not be deleted.
202  \ingroup rp_func
203  */
205  const te::rst::Raster& inputRaster,
206  const std::string& fileName );
207 
208  /*!
209  \brief Returns the real data type range (all values that can be represented by the given data type).
210  \param dataType The data type.
211  \param min The minimum value.
212  \param max The maximum value.
213  \note The types are listed in terralib/datatype/DataTypes.h
214  \ingroup rp_func
215  */
216  inline void TERPEXPORT GetDataTypeRange( const int dataType, double& min, double& max )
217  {
218  te::rst::GetDataTypeRanges( dataType, min, max );
219  }
220 
221  /*!
222  \brief Convert vector elements.
223  \param inputVector Input vector.
224  \param inputVectorDataType Input vector data type.
225  \param inputVectorSize The numer of input vector elements.
226  \param outputVector A pré-allocated output vector.
227  \note The types are listed in terralib/datatype/DataTypes.h
228  \ingroup rp_func
229  */
230  void TERPEXPORT Convert2DoublesVector( void* inputVector, const int inputVectorDataType,
231  unsigned int inputVectorSize, double* outputVector );
232 
233  /*!
234  \brief Convert a doubles vector.
235  \param inputVector Input vector.
236  \param inputVectorSize The numer of input vector elements.
237  \param inputVectorDataType Input vector data type.
238  \param outputVector A pré-allocated output vector.
239  \note The types are listed in terralib/datatype/DataTypes.h
240  \ingroup rp_func
241  */
242  void TERPEXPORT ConvertDoublesVector( double* inputVector,
243  unsigned int inputVectorSize, const int outputVectorDataType,
244  void* outputVector );
245 
246  /*!
247  \brief Create a tiff file from a matrix.
248  \param matrix The matrix.
249  \param normalize Enable/disable pixel normalization (8bit);
250  \param tifFileName Tif file name.
251  \param return true if OK, false on errors.
252  \ingroup rp_func
253  */
254  template< typename MatrixElementT >
256  const bool normalize, const std::string& fileName )
257  {
258  std::map<std::string, std::string> rInfo;
259  rInfo["URI"] = fileName;
260 
261  std::vector<te::rst::BandProperty*> bandsProperties;
262  if( normalize )
263  bandsProperties.push_back(new te::rst::BandProperty( 0, te::dt::UCHAR_TYPE, "" ));
264  else
265  bandsProperties.push_back(new te::rst::BandProperty( 0, te::dt::DOUBLE_TYPE, "" ));
266  bandsProperties[0]->m_colorInterp = te::rst::GrayIdxCInt;
267  bandsProperties[0]->m_noDataValue = -1.0 * std::numeric_limits<double>::max();
268 
269  te::rst::Grid* newgrid = new te::rst::Grid( matrix.getColumnsNumber(),
270  matrix.getLinesNumber(), 0, -1 );
271 
272  std::unique_ptr< te::rst::Raster > outputRasterPtr(
273  te::rst::RasterFactory::make( "GDAL", newgrid, bandsProperties, rInfo, 0, 0));
274  TERP_TRUE_OR_RETURN_FALSE( outputRasterPtr.get(), "Output raster creation error");
275 
276  unsigned int line = 0;
277  unsigned int col = 0;
278  const unsigned int nLines = matrix.getLinesNumber();
279  const unsigned int nCols = matrix.getColumnsNumber();
280  MatrixElementT matrixValue = 0;
281 
282  MatrixElementT gain = 1.0;
283  MatrixElementT offset = 0.0;
284  if( normalize )
285  {
286  MatrixElementT matrixValueMin = std::numeric_limits< MatrixElementT >::max();
287  MatrixElementT matrixValueMax = -1.0 * matrixValueMin;
288  for( line = 0 ; line < nLines ; ++line )
289  {
290  for( col = 0 ; col < nCols ; ++col )
291  {
292  matrixValue = matrix[ line ][ col ];
293  if( matrixValue < matrixValueMin )
294  matrixValueMin = matrixValue;
295  if( matrixValue > matrixValueMax )
296  matrixValueMax = matrixValue;
297  }
298  }
299 
300  if( matrixValueMax == matrixValueMin )
301  {
302  gain = 0.0;
303  offset = 0.0;
304  }
305  else
306  {
307  gain = 255.0 / ( matrixValueMax - matrixValueMin );
308  offset = -1.0 * ( matrixValueMin );
309  }
310  }
311 
312  const MatrixElementT min0 = 0;
313  const MatrixElementT max255 = 255;
314 
315  for( line = 0 ; line < nLines ; ++line )
316  {
317  for( col = 0 ; col < nCols ; ++col )
318  {
319  matrixValue = matrix[ line ][ col ];
320 
321  if( normalize )
322  {
323  matrixValue += offset;
324  matrixValue *= gain;
325  matrixValue = std::max( min0, matrixValue );
326  matrixValue = std::min( max255, matrixValue );
327  }
328 
329  outputRasterPtr->setValue( col, line, static_cast<double>(matrixValue), 0 );
330  }
331  }
332 
333  return true;
334  }
335 
336  /*!
337  \brief Returns a json filename with spectral sensors parameters.
338  \ingroup rp_func
339  */
341 
342  /*!
343  \brief Returns a vector os with band's names.
344  \ingroup rp_func
345  */
346  TERPEXPORT std::vector<std::string> GetBandNames();
347 
348  /*!
349  \brief Returns a map with spectral sensors parameters defined in SpectralSensor.json file.
350  \ingroup rp_func
351  */
352  TERPEXPORT std::map<std::string, SpectralSensorParams > getSensorParams();
353 
354  /*!
355  \brief Saves in SpectralSensor.json file the spectral sensors parameters.
356  \ingroup rp_func
357  */
358  TERPEXPORT void SaveSensorParams(std::map<std::string, SpectralSensorParams > &);
359 
360  /*!
361  \brief Returns the maximun and minimum reflectance values of a given sensor/band.
362  \ingroup rp_func
363  */
365 
366  /*!
367  \brief Returns the minimum reflectance value of a given sensor/band.
368  \ingroup rp_func
369  */
370  TERPEXPORT double GetSpectralBandMin(std::string bandName);
371 
372  /*!
373  \brief Returns the maximum reflectance value of a given sensor/band.
374  \ingroup rp_func
375  */
376  TERPEXPORT double GetSpectralBandMax(std::string bandName);
377 
378  /*!
379  \brief Returns the maximun and minimum digital numbers of a given sensor/band.
380  \ingroup rp_func
381  */
382  TERPEXPORT std::pair<double, double> GetDigitalNumberBandInfo(std::string bandName);
383 
384  /*!
385  \brief Returns the maximum digital number of a given sensor/band.
386  \ingroup rp_func
387  */
388  TERPEXPORT double GetDigitalNumberBandMax(std::string bandName);
389 
390  /*!
391  \brief Returns the minimum digital number of a given sensor/band.
392  \ingroup rp_func
393  */
394  TERPEXPORT double GetDigitalNumberBandMin(std::string bandName);
395 
396  /*!
397  \brief Normalizes one raster in a given interval.
398 
399  \param inputRaster The given raster.
400  \param nmin The new minimum value (default = 0.0).
401  \param nmax The new maximum value (default = 255.0).
402 
403  \return true if normalization occurs and false otherwise.
404  \ingroup rp_func
405  */
406  TERPEXPORT bool NormalizeRaster(te::rst::Raster& inputRaster, double nmin = 0.0, double nmax = 255.0);
407 
408  /*!
409  \brief Normalizes a raster in a given interval.
410 
411  \param inputRaster The given raster.
412 
413  \return a raster normalized.
414  \ingroup rp_func
415  */
417 
418  /*!
419  \brief RGB to IHS conversion.
420  \param inputRGBRaster The input raster.
421  \param redBandIdx The red band index.
422  \param greenBandIdx The red band index.
423  \param blueBandIdx The red band index.
424  \param rgbRangeMin The minimum RGB value.
425  \param rgbRangeMax The maximum RGB value.
426  \param outputIHSRaster An output pré-initiated raster (with the same dimensions of inputRGBRaster) where the IHS data will be written (double or float as the data type).
427  \return true if OK, false on errors.
428  \note The outputIHSRaster mas have a float or double data type.
429  \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
430  \ingroup rp_func
431  */
432  TERPEXPORT bool ConvertRGB2IHS( const te::rst::Raster& inputRGBRaster,
433  const unsigned int redBandIdx, const unsigned int greenBandIdx,
434  const unsigned int blueBandIdx, const double rgbRangeMin,
435  const double rgbRangeMax, te::rst::Raster& outputIHSRaster );
436 
437  /*!
438  \brief RGB to IHS conversion.
439  \param inputRedRaster The input red raster.
440  \param redBandIdx The red band index.
441  \param inputGreenRaster The input green raster.
442  \param greenBandIdx The green band index.
443  \param inputBlueRaster The input blue raster.
444  \param blueBandIdx The blue band index.
445  \param rgbRangeMin The minimum RGB value.
446  \param rgbRangeMax The maximum RGB value.
447  \param outputIHSRaster An output pré-initiated raster (with the same dimensions of inputRGBRaster) where the IHS data will be written (double or float as the data type).
448  \return true if OK, false on errors.
449  \note The outputIHSRaster mas have a float or double data type.
450  \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
451  \ingroup rp_func
452  */
453  TERPEXPORT bool ConvertRGB2IHS(const te::rst::Raster& inputRedRaster, const unsigned int redBandIdx,
454  const te::rst::Raster& inputGreenRaster, const unsigned int greenBandIdx,
455  const te::rst::Raster& inputBlueRaster, const unsigned int blueBandIdx,
456  const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputIHSRaster);
457 
458  /*!
459  \brief IHS to RGB conversion.
460  \param inputIHSRaster The input raster.
461  \param intensityBandIdx The intensity band index.
462  \param hueBandIdx The hue band index.
463  \param saturationBandIdx The saturation band index.
464  \param rgbRangeMin The minimum RGB value.
465  \param rgbRangeMax The maximum RGB value.
466  \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputIHSRaster) where the RGB data will be written.
467  \return true if OK, false on errors.
468  \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
469  \ingroup rp_func
470  */
471  TERPEXPORT bool ConvertIHS2RGB( const te::rst::Raster& inputIHSRaster,
472  const unsigned int intensityBandIdx, const unsigned int hueBandIdx,
473  const unsigned int saturationBandIdx, const double rgbRangeMin,
474  const double rgbRangeMax, te::rst::Raster& outputRGBRaster );
475 
476  /*!
477  \brief IHS to RGB conversion.
478  \param inputIRaster The input intensity raster.
479  \param intensityBandIdx The intensity band index.
480  \param inputHRaster The input hue raster.
481  \param hueBandIdx The hue band index.
482  \param inputSRaster The input saturation raster.
483  \param saturationBandIdx The saturation band index.
484  \param rgbRangeMin The minimum RGB value.
485  \param rgbRangeMax The maximum RGB value.
486  \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputIHSRaster) where the RGB data will be written.
487  \return true if OK, false on errors.
488  \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
489  \ingroup rp_func
490  */
491  TERPEXPORT bool ConvertIHS2RGB(const te::rst::Raster& inputIRaster, const unsigned int intensityBandIdx,
492  const te::rst::Raster& inputHRaster, const unsigned int hueBandIdx,
493  const te::rst::Raster& inputSRaster, const unsigned int saturationBandIdx,
494  const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputRGBRaster);
495 
496  /*!
497  \brief RGB to HLS conversion.
498  \param inputRGBRaster The input raster.
499  \param redBandIdx The red band index.
500  \param greenBandIdx The red band index.
501  \param blueBandIdx The red band index.
502  \param rgbRangeMin The minimum RGB value.
503  \param rgbRangeMax The maximum RGB value.
504  \param outputHLSRaster An output pré-initiated raster (with the same dimensions of inputRGBRaster) where the HLS data will be written (double or float as the data type).
505  \return true if OK, false on errors.
506  \note The outputHLSRaster mas have a float or double data type.
507  \ingroup rp_func
508  */
509  TERPEXPORT bool ConvertRGB2HLS(const te::rst::Raster& inputRGBRaster,
510  const unsigned int redBandIdx, const unsigned int greenBandIdx,
511  const unsigned int blueBandIdx, const double rgbRangeMin,
512  const double rgbRangeMax, te::rst::Raster& outputHLSRaster);
513 
514  /*!
515  \brief RGB to HLS conversion.
516  \param inputRedRaster The input red raster.
517  \param redBandIdx The red band index.
518  \param inputGreenRaster The input green raster.
519  \param greenBandIdx The green band index.
520  \param inputBlueRaster The input blue raster.
521  \param blueBandIdx The blue band index.
522  \param rgbRangeMin The minimum RGB value.
523  \param rgbRangeMax The maximum RGB value.
524  \param outputHLSRaster An output pré-initiated raster (with the same dimensions of inputRGBRaster) where the HLS data will be written (double or float as the data type).
525  \return true if OK, false on errors.
526  \note The outputHLSRaster mas have a float or double data type.
527  \ingroup rp_func
528  */
529  TERPEXPORT bool ConvertRGB2HLS(const te::rst::Raster& inputRedRaster, const unsigned int redBandIdx,
530  const te::rst::Raster& inputGreenRaster, const unsigned int greenBandIdx,
531  const te::rst::Raster& inputBlueRaster, const unsigned int blueBandIdx,
532  const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputHLSRaster);
533 
534  /*!
535  \brief HLS to RGB conversion.
536  \param inputHLSRaster The input raster.
537  \param hueBandIdx The hue band index.
538  \param lightBandIdx The light band index.
539  \param saturationBandIdx The saturation band index.
540  \param rgbRangeMin The minimum RGB value.
541  \param rgbRangeMax The maximum RGB value.
542  \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputHLSRaster) where the RGB data will be written.
543  \return true if OK, false on errors.
544  \ingroup rp_func
545  */
546  TERPEXPORT bool ConvertHLS2RGB(const te::rst::Raster& inputHLSRaster,
547  const unsigned int hueBandIdx, const unsigned int lightBandIdx,
548  const unsigned int saturationBandIdx, const double rgbRangeMin,
549  const double rgbRangeMax, te::rst::Raster& outputRGBRaster);
550 
551  /*!
552  \brief HLS to RGB conversion.
553  \param inputHRaster The input hue raster.
554  \param hueBandIdx The hue band index.
555  \param inputLRaster The input light raster.
556  \param lightBandIdx The light band index.
557  \param inputSRaster The input saturation raster.
558  \param saturationBandIdx The saturation band index.
559  \param rgbRangeMin The minimum RGB value.
560  \param rgbRangeMax The maximum RGB value.
561  \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputHLSRaster) where the RGB data will be written.
562  \return true if OK, false on errors.
563  \ingroup rp_func
564  */
565  TERPEXPORT bool ConvertHLS2RGB(const te::rst::Raster& inputHRaster, const unsigned int hueBandIdx,
566  const te::rst::Raster& inputLRaster, const unsigned int lightBandIdx,
567  const te::rst::Raster& inputSRaster, const unsigned int saturationBandIdx,
568  const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputRGBRaster);
569 
570  /*!
571  \brief Get the mean of band pixel values.
572  \param inputRaster The input raster.
573  \param inputBandIndex Input band index.
574  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
575  \param meanValue The calculated mean value.
576  \return true if OK, false on errors.
577  \note Optimized for rasters where the used bands have the same blocking scheme.
578  \ingroup rp_func
579  */
581  const te::rst::Raster& inputRaster,
582  const unsigned int inputBandIndex,
583  const unsigned int maxThreads,
584  double& meanValue );
585 
586  /*!
587  \brief Get the standard deviation of band pixel values.
588  \param inputRaster The input raster.
589  \param inputBandIndex Input band index.
590  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
591  \param meanValuePtr A pointer to a pre-calculated band mean value or zero if it does not exist.
592  \param stdDevValue The calculated standard deviation value.
593  \return true if OK, false on errors.
594  \note Optimized for rasters where the used bands have the same blocking scheme.
595  \ingroup rp_func
596  */
598  const te::rst::Raster& inputRaster,
599  const unsigned int inputBandIndex,
600  const unsigned int maxThreads,
601  double const * const meanValuePtr,
602  double& stdDevValue );
603 
604  /*!
605  \brief Get the covariance of band pixel values.
606  \param inputRaster1 The input raster 1.
607  \param inputBandIndex1 Input raster 1 band index.
608  \param inputRaster2 The input raster 2.
609  \param inputBandIndex2 Input raster 2 band index.
610  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
611  \param mean1ValuePtr A pointer to a pre-calculated band1 mean value or zero if it does not exist.
612  \param mean2ValuePtr A pointer to a pre-calculated band2 mean value or zero if it does not exist.
613  \param covarianceValue The calculated covariance value.
614  \return true if OK, false on errors.
615  \ingroup rp_func
616  */
618  const te::rst::Raster& inputRaster1,
619  const unsigned int inputBandIndex1,
620  const te::rst::Raster& inputRaster2,
621  const unsigned int inputBandIndex2,
622  const unsigned int maxThreads,
623  double const * const mean1ValuePtr,
624  double const * const mean2ValuePtr,
625  double& covarianceValue );
626 
627  /*!
628  \brief Generate all principal components from the given input raster.
629  \param inputRaster Input raster.
630  \param inputRasterBands Input raster bands.
631  \param pcaMatrix The matrix generated over the principal components process.
632  \param pcaRaster The pré-initiated output PCA raster (with the same dimensions of inputRaster) and double as the data type.
633  \param pcaRasterBands Output raster bands.
634  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
635  \return true if OK, false on errors.
636  \note Optimized for rasters where the used bands have the same blocking scheme.
637  \ingroup rp_func
638  */
640  const te::rst::Raster& inputRaster,
641  const std::vector< unsigned int >& inputRasterBands,
642  boost::numeric::ublas::matrix< double >& pcaMatrix,
643  te::rst::Raster& pcaRaster,
644  const std::vector< unsigned int >& pcaRasterBands,
645  const unsigned int maxThreads );
646 
647  /*!
648  \brief Regenerate the original raster from its principal components.
649  \param pcaRaster The principal components raster (with the same dimensions of outputRaster).
650  \param pcaMatrix The matrix generated by the direct principal components process.
651  \param outputRaster The regenerated output raster (with the same dimentions.
652  \param outputRasterBands Output raster bands.
653  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
654  \return true if OK, false on errors.
655  \note Optimized for rasters where the used bands have the same blocking scheme.
656  \ingroup rp_func
657  */
659  const te::rst::Raster& pcaRaster,
660  const boost::numeric::ublas::matrix< double >& pcaMatrix,
661  te::rst::Raster& outputRaster,
662  const std::vector< unsigned int >& outputRasterBands,
663  const unsigned int maxThreads );
664 
665  /*!
666  \brief Remap all pixel values using a user supplied target values (non-target values are just copied from input to output).
667  \param inputRaster Input raster.
668  \param inputRasterBandIdx Input raster band.
669  \param targetValues A vector of target values pairs in the form: std::pair< old_value, new_value >.
670  \param enableProgress Enable/disable the progress interface.
671  \param restrictionPols A vector of polygons where the remap must be executed or an empty vector indicating all pixels must be remapped.
672  \param outputRaster The pré-initiated output raster.
673  \param outputRasterBandIdx Output raster band.
674  \return true if OK, false on errors.
675  \note Optimized for rasters where the used bands have the same blocking scheme.
676  \ingroup rp_func
677  */
679  const te::rst::Raster& inputRaster,
680  const unsigned int& inputRasterBandIdx,
681  const std::vector< std::pair< double, double > >& targetValues,
682  const bool enableProgress,
683  const std::vector< te::gm::Polygon* >& restrictionPols,
684  te::rst::Raster& outputRaster,
685  const unsigned int& outputRasterBandIdx );
686 
687  /*!
688  \brief Remap pixel values using a remap function matrix.
689  \param inputRaster Input raster.
690  \param inputRasterBands Input raster bands.
691  \param remapMatrix The remap function matrix.
692  \param outputRaster The pré-initiated output raster (with the same dimentions of inputRaster).
693  \param outputRasterBands Output raster bands.
694  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
695  \return true if OK, false on errors.
696  \note Optimized for rasters where the used bands have the same blocking scheme.
697  \ingroup rp_func
698  */
700  const te::rst::Raster& inputRaster,
701  const std::vector< unsigned int >& inputRasterBands,
702  const boost::numeric::ublas::matrix< double >& remapMatrix,
703  te::rst::Raster& outputRaster,
704  const std::vector< unsigned int >& outputRasterBands,
705  const unsigned int maxThreads );
706 
707  /*!
708  \brief Decompose a multi-band raster into a set of one-band rasters.
709  \param inputRaster Input raster.
710  \param inputRasterBands Input raster bands.
711  \param outputRastersInfos Output rasters connections infos. (one info for each decomposed band).
712  \param outputDataSourceType Output raster datasource type.
713  \param outputRastersPtrs Pointers to the generated outputs rasters.
714  \return true if OK, false on errors.
715  \ingroup rp_func
716  */
718  const te::rst::Raster& inputRaster,
719  const std::vector< unsigned int >& inputRasterBands,
720  const std::vector< std::map<std::string, std::string> > & outputRastersInfos,
721  const std::string& outputDataSourceType,
722  std::vector< boost::shared_ptr< te::rst::Raster > > & outputRastersPtrs );
723 
724  /*!
725  \brief Compose a set of bands into one multi-band raster.
726  \param feeder Input rasters feeder.
727  \param inputRasterBands Input raster bands (one band for each input raster).
728  \param interpMethod The interpolator method to use.
729  \param outputRasterInfo Output raster connection info.
730  \param outputDataSourceType Output raster datasource type.
731  \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
732  \param outputRasterPtr A pointer to the generated output raster.
733  \return true if OK, false on errors.
734  \note The first raster Grid will be taken as reference for the composed raster.
735  \ingroup rp_func
736  */
739  const std::vector< unsigned int >& inputRasterBands,
740  const te::rst::Interpolator::Method& interpMethod,
741  const std::map<std::string, std::string>& outputRasterInfo,
742  const std::string& outputDataSourceType,
743  const unsigned int maxThreads,
744  std::unique_ptr< te::rst::Raster >& outputRasterPtr );
745 
746  /*!
747  \brief Create a datailed extent from the given grid.
748  \param grid Input grid.
749  \param detailedExtent The created detailed extent.
750  \return true if ok, false on errors.
751  \ingroup rp_func
752  */
754  te::gm::LinearRing& detailedExtent );
755 
756  /*!
757  \brief Create a indexed (lines,columns) datailed extent from the given grid.
758  \param grid Input grid.
759  \param indexedDetailedExtent The created detailed extent.
760  \return true if ok, false on errors.
761  \ingroup rp_func
762  */
764  te::gm::LinearRing& indexedDetailedExtent );
765 
766  /*!
767  \brief Create a Wavele Atrous Filter.
768  \param filterType The filter type.
769  \return the created filter.
770  \ingroup rp_func
771  */
772  TERPEXPORT boost::numeric::ublas::matrix< double >
774 
775  /*!
776  \brief Generate all wavelet planes from the given input raster.
777  \param inputRaster Input raster.
778  \param inputRasterBands Input raster bands.
779  \param waveletRaster The pré-initiated output wavelet raster (with the same dimensions of inputRaster) and double as the data type.
780  \param levelsNumber The number of decomposed wavelet levels to generate for each input raster band;
781  \param filter The square filter to use.
782  \return true if OK, false on errors.
783  \note The band order of the generated wavelet levels: { [ band0-smoothed0, band0-wavelet0, ... , band0-smoothedN, band0-waveletN ], ... }
784  \note The number of bands of waveletRaster must be ( inputRasterBands.size() * 2 * levelsNumber ) at least.
785  \ingroup rp_func
786  */
788  const te::rst::Raster& inputRaster,
789  const std::vector< unsigned int >& inputRasterBands,
790  te::rst::Raster& waveletRaster,
791  const unsigned int levelsNumber,
792  const boost::numeric::ublas::matrix< double >& filter );
793 
794  /*!
795  \brief Regenerate the original raster from its wavelets planes.
796  \param waveletRaster The input wavelet raster (with the same dimensions of outputRaster).
797  \param levelsNumber The number of decomposed wavelet levels present inside the wavelet raster.
798  \param outputRaster The regenerated output raster.
799  \param outputRasterBands Output raster bands.
800  \return true if OK, false on errors.
801  \note The band order of the expected wavelet levels: { [ band0-smoothed0, band0-wavelet0, ... , band0-smoothedN, band0-waveletN ], ... }
802  \note The number of bands of waveletRaster must be ( outputRasterBands.size() * 2 * levelsNumber ) at least.
803  \note Only the wavelet bands and the last smoothed band are used.
804  \ingroup rp_func
805  */
807  const te::rst::Raster& waveletRaster,
808  const unsigned int levelsNumber,
809  te::rst::Raster& outputRaster,
810  const std::vector< unsigned int >& outputRasterBands );
811 
812  /*!
813  \brief Resample a subset of the raster, given a box.
814  \param inputRaster Input raster.
815  \param inputRasterBands Input raster bands to process.
816  \param interpMethod The method of interpolation. \sa te::rst::Interpolator
817  \param interpWindowRadius Interpolator windows radius around the target pixel (when applicable).
818  \param firstRow The starting row to make a subset of the image.
819  \param firstColumn The starting column to make a subset of the image.
820  \param height The height of the subset.
821  \param width The width of the subset.
822  \param newheight The resampled height of the new raster.
823  \param newwidth The resampled width of the new raster.
824  \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
825  \param dataSourceType Data source type (raster type. I.E. GDAL).
826  \param resampledRasterPtr The resampled raster pointer.
827  \return true if ok, false on errors.
828  */
830  const te::rst::Raster& inputRaster,
831  const std::vector< unsigned int >& inputRasterBands,
832  const te::rst::Interpolator::Method interpMethod,
833  const unsigned int interpWindowRadius,
834  const unsigned int firstRow,
835  const unsigned int firstColumn,
836  const unsigned int height,
837  const unsigned int width,
838  const unsigned int newheight,
839  const unsigned int newwidth,
840  const std::map<std::string, std::string>& rinfo,
841  const std::string& dataSourceType,
842  std::unique_ptr< te::rst::Raster >& resampledRasterPtr );
843 
844  /*!
845  \brief Returns the tie points converx hull area.
846  \param tiePoints Input tie-points (container of te::gm::GTParameters::TiePoint).
847  \param useTPSecondCoordPair If true the sencond tie-point component (te::gm::GTParameters::TiePoint::second) will be used for the area calcule, otherwize the first component will be used.
848  \return Returns the tie points converx hull area.
849  */
850  template< typename ContainerT >
851  double GetTPConvexHullArea( const ContainerT& tiePoints,
852  const bool useTPSecondCoordPair )
853  {
854  if( tiePoints.size() < 3 )
855  {
856  return 0;
857  }
858  else
859  {
861 
862  typename ContainerT::const_iterator it =
863  tiePoints.begin();
864  const typename ContainerT::const_iterator itE =
865  tiePoints.end();
866 
867  while( it != itE )
868  {
869  if( useTPSecondCoordPair )
870  points.add(new te::gm::Point(it->second.x, it->second.y));
871  else
872  points.add(new te::gm::Point(it->first.x, it->first.y));
873 
874  ++it;
875  }
876 
877  std::unique_ptr< te::gm::Geometry > convexHullPolPtr( points.convexHull() );
878 
879  if( dynamic_cast< te::gm::Surface* >( convexHullPolPtr.get() ) )
880  {
881  return ( (te::gm::Surface*)( convexHullPolPtr.get() ) )->getArea();
882  }
883  else
884  {
885  return 0.0;
886  }
887  }
888  }
889 
890  /*!
891  \brief Create a fixed step sequential color palette.
892  \param paletteSize The desired palette size.
893  \param palette The crated palette.
894  */
896  const unsigned int paletteSize,
897  const bool randomize,
898  std::vector< te::rst::BandProperty::ColorEntry >& palette );
899 
900  /*!
901  \brief Create a new raster grouping pixel values following the number of slices and/or slice limits.
902  \param inputRaster Input raster.
903  \param inputRasterBand Input raster band.
904  \param createPaletteRaster If true a paletted raster will be created instead of a multi-band raster..
905  \param slicesNumber The number of histogram slices to create;
906  \param eqHistogram If true, the input raster will be equalized before the slicing process.
907  \param rasterInfo The output raster info (specific driver info).
908  \param rasterType The output raster type (specific driver name - See te::rst::RasterFactory dictorary for more info).
909  \param enableProgress Enable/disable the progress interface.
910  \param palettePtr A pointer to an optional user given palette (if null, an fixed step pallete will be generated).
911  \param outRasterPtr The output sliced raster pointer.
912  \param slicesLimitsPtr A null pointer or a pointer to a container of slice limits ( the small of the the values for each slice range ).
913  \param slicesOutputValuesPtr A null pointer or a pointer to a vector of output raster values related to each slice.
914  \return true if OK, false on errors.
915  \ingroup rp_func
916  */
918  const te::rst::Raster& inputRaster,
919  const unsigned int inputRasterBand,
920  const bool createPaletteRaster,
921  const unsigned int slicesNumber,
922  const bool eqHistogram,
923  const std::map< std::string, std::string >& rasterInfo,
924  const std::string& rasterType,
925  const bool enableProgress,
926  std::vector< te::rst::BandProperty::ColorEntry > const * const palettePtr,
927  std::unique_ptr< te::rst::Raster >& outRasterPtr,
928  std::vector< double > const* slicesLimitsPtr,
929  std::vector< double > const* slicesOutputValuesPtr );
930 
931  /*!
932  \brief Replace a contiguos segment pixel values.
933  \param inputRaster Input raster.
934  \param inputRasterBandIdx Input raster band to use.
935  \param targetRow Target row (a point inside the target segment).
936  \param targetCol Target col (a point inside the target segment).
937  \param outputValue Output segment final value.
938  \return true if OK, false on errors.
939  \ingroup rp_func
940  */
942  te::rst::Raster& inputRaster,
943  const unsigned int& inputRasterBandIdx,
944  const unsigned targetRow,
945  const unsigned targetCol,
946  const double& outputValue );
947 
948  /*!
949  \brief Replace a contiguos segment pixel values.
950  \param inputRaster Input raster.
951  \param inputRasterBandIdx Input raster band to use.
952  \param outputRaster Input raster.
953  \param outputRasterBandIdx Input raster band to use.
954  \param targetRow Target row (a point inside the target segment).
955  \param targetCol Target col (a point inside the target segment).
956  \param outputValue Output segment final value.
957  \return true if OK, false on errors.
958  \ingroup rp_func
959  */
961  const te::rst::Raster& inputRaster,
962  const unsigned int& inputRasterBandIdx,
963  te::rst::Raster& outputRaster,
964  const unsigned int& outputRasterBandIdx,
965  const unsigned targetInputRow,
966  const unsigned targetInputCol,
967  const double& outputValue );
968 
969  /*!
970  \brief Compute and return the histogram soccurring values (real and imaginary) inside defined regions of interest.
971 
972  \param raster Input raster.
973  \param bandIndex Band index.
974  \param rois Regions of interest (under the same SRID as the input raster) or an empty vector for the case where all the image must be processed.
975  \param histoBins The number of bins (intervals from minimum pixel to maximum). When b = 0, the histogram will be divided according to all pixel values.
976  \param maxThreads Maximum number of used threads to use (0-Automatic, 1-No threads used).
977  \param roisItType ROIs polygons iteration type.
978  \param rHistogram The generated histogram (real).
979  \param iHistogram The generated histogram (imaginary).
980  \return true if ok, false on errors
981  \note This method will ignore storage specific tags and will read all raster data to compute the histograms (use te::rst::Band methods to use storage specifc tags).
982  */
984  const te::rst::Raster& raster,
985  const unsigned int bandIndex,
986  const std::vector< te::gm::Polygon const* >& rois,
987  const unsigned int histoBins,
988  const unsigned int maxThreads,
990  std::map<double, unsigned>& rHistogram,
991  std::map<double, unsigned>& iHistogram );
992 
993  /*!
994  \brief Compute statiscts from the given histogram.
995 
996  \param histogram Input histogram.
997  \param min Histogram minimun value.
998  \param max Histogram maximum value.
999  \param mean Histogram mean value.
1000  \param stdDev Histogram standard deviation value.
1001  \param mode Histogram mode value.
1002  \param entropy Histogram mode value.
1003  \param sum Sum of all pixels values.
1004  \param sum2 Quadratic sum of all pixels values.
1005  \param sum3 The cubic sum of pixels values.
1006  \param sum4 The quartic sum of pixels values.
1007  \param variance Histogram variance value.
1008  \param median Histogram median value.
1009  */
1011  const std::map<double, unsigned int>& histogram,
1012  double& min,
1013  double& max,
1014  double& mean,
1015  double& stdDev,
1016  double& mode,
1017  double& entropy,
1018  double& sum,
1019  double& sum2,
1020  double& sum3,
1021  double& sum4,
1022  double& variance,
1023  double& median
1024  );
1025 
1026  /*!
1027  \brief Compute and return the joint histogram of occurring values (real and imaginary) inside defined regions of interest.
1028  \param raster Input raster.
1029  \param bandIndex1 Input raster Band 1 index.
1030  \param bandIndex2 Input raster Band 2 index.
1031  \param rois Regions of interest (under the same SRID as the input raster) or an empty vector for the case where all the image must be processed.
1032  \param histoBins The number of bins (intervals from minimum pixel to maximum). When b = 0, the histogram will be divided according to all pixel values.
1033  \param maxThreads Maximum number of used threads to use (0-Automatic, 1-No threads used).
1034  \param roisItType ROIs polygons iteration type.
1035  \param realJointHistogram The generated joint histogram (real).
1036  \param imagJointHistogram The generated joint histogram (imaginary).
1037  \param rasterRealHistogram1ptr A pointer to a pre-calculated input raster band 1 histogram (real) or a null pointer.
1038  \param rasterImagHistogram1Ptr A pointer to a pre-calculated input raster band 1 histogram (imaginary) or a null pointer.
1039  \param rasterRealHistogram2Ptr A pointer to a pre-calculated input raster band 2 histogram (real) or a null pointer.
1040  \param rasterImagHistogram2Ptr A pointer to a pre-calculated input raster band 2 histogram (imaginary) or a null pointer.
1041  \return true if ok, false on errors
1042  \note This method will ignore storage specific tags and will read all raster data to compute the histograms (use te::rst::Band methods to use storage specifc tags).
1043  */
1045  const te::rst::Raster& raster,
1046  const unsigned int bandIndex1,
1047  const unsigned int bandIndex2,
1048  const std::vector< te::gm::Polygon const* >& rois,
1049  const unsigned int histoBins,
1050  const unsigned int maxThreads,
1052  std::map< std::pair< double, double >, unsigned int>& realJointHistogram,
1053  std::map< std::pair< double, double >, unsigned int>& imagJointHistogram,
1054  std::map<double, unsigned int> const * const rasterRealHistogram1ptr,
1055  std::map<double, unsigned int> const * const rasterImagHistogram1Ptr,
1056  std::map<double, unsigned int> const * const rasterRealHistogram2Ptr,
1057  std::map<double, unsigned int> const * const rasterImagHistogram2Ptr );
1058 
1059  /*!
1060  \brief Compute statiscts from the given histogram.
1061 
1062  \param jointHistogram Input joint histogram where std::pair< double, double >.first are histogram1 values and std::pair< double, double >.second are histogram2 values
1063  \param histogram1 Histogram 1.
1064  \param histogram2 Histogram 2.
1065  \param covariance Calculated covariance value.
1066  \return true if ok, false on errors.
1067  */
1069  const std::map< std::pair< double, double >, unsigned int>& jointHistogram,
1070  const std::map<double, unsigned int>& histogram1,
1071  const std::map<double, unsigned int>& histogram2,
1072  double& covariance );
1073 
1074  } // end namespace rp
1075 } // end namespace te
1076 
1077 #endif // __TERRALIB_RP_INTERNAL_FUNCTIONS_H
1078 
te::rp::GetTPConvexHullArea
double GetTPConvexHullArea(const ContainerT &tiePoints, const bool useTPSecondCoordPair)
Returns the tie points converx hull area.
Definition: Functions.h:851
te::gm::MultiPoint
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:54
te::rp::SelectiveReplaceValues
TERPEXPORT bool SelectiveReplaceValues(const te::rst::Raster &inputRaster, const unsigned int &inputRasterBandIdx, const std::vector< std::pair< double, double > > &targetValues, const bool enableProgress, const std::vector< te::gm::Polygon * > &restrictionPols, te::rst::Raster &outputRaster, const unsigned int &outputRasterBandIdx)
Remap all pixel values using a user supplied target values (non-target values are just copied from in...
te::dt::DOUBLE_TYPE
@ DOUBLE_TYPE
Definition: Enums.h:198
te::rp::Matrix
A generic template matrix.
Definition: Matrix.h:55
te::rp::RasterResample
TERPEXPORT bool RasterResample(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const te::rst::Interpolator::Method interpMethod, const unsigned int interpWindowRadius, const unsigned int firstRow, const unsigned int firstColumn, const unsigned int height, const unsigned int width, const unsigned int newheight, const unsigned int newwidth, const std::map< std::string, std::string > &rinfo, const std::string &dataSourceType, std::unique_ptr< te::rst::Raster > &resampledRasterPtr)
Resample a subset of the raster, given a box.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::B3SplineWAFilter
@ B3SplineWAFilter
Spline filter type.
Definition: Functions.h:77
te::rp::GetDigitalNumberBandMax
TERPEXPORT double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band.
te::rp::RasterHandler
RasterHandler.
Definition: RasterHandler.h:48
te::rst::GrayIdxCInt
@ GrayIdxCInt
Index into a lookup table.
Definition: Enums.h:57
te::rst::GetDataTypeRanges
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
Macros.h
te::rp::SpectralSensorParams::m_max
double m_max
Definition: Functions.h:97
te::rp::SpectralSensorParams::SpectralSensorParams
SpectralSensorParams(const int &band, const double &lower, const double &upper, const double &min, const double &max)
Definition: Functions.h:85
te::rp::CreateFixedStepPalette
TERPEXPORT void CreateFixedStepPalette(const unsigned int paletteSize, const bool randomize, std::vector< te::rst::BandProperty::ColorEntry > &palette)
Create a fixed step sequential color palette.
te::rp::GetDataTypeRange
void TERPEXPORT GetDataTypeRange(const int dataType, double &min, double &max)
Returns the real data type range (all values that can be represented by the given data type).
Definition: Functions.h:216
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::rp::CreateNewMemRaster
bool TERPEXPORT CreateNewMemRaster(const te::rst::Grid &rasterGrid, std::vector< te::rst::BandProperty * > bandsProperties, RasterHandler &outRasterHandler)
Create a new raster into a new memory datasource.
te::rp::RasterSlicing
TERPEXPORT bool RasterSlicing(const te::rst::Raster &inputRaster, const unsigned int inputRasterBand, const bool createPaletteRaster, const unsigned int slicesNumber, const bool eqHistogram, const std::map< std::string, std::string > &rasterInfo, const std::string &rasterType, const bool enableProgress, std::vector< te::rst::BandProperty::ColorEntry > const *const palettePtr, std::unique_ptr< te::rst::Raster > &outRasterPtr, std::vector< double > const *slicesLimitsPtr, std::vector< double > const *slicesOutputValuesPtr)
Create a new raster grouping pixel values following the number of slices and/or slice limits.
te::gm::MultiPointType
@ MultiPointType
Definition: Enums.h:84
te::rp::GetBandNames
TERPEXPORT std::vector< std::string > GetBandNames()
Returns a vector os with band's names.
te::rp::GetCovarianceValue
TERPEXPORT bool GetCovarianceValue(const te::rst::Raster &inputRaster1, const unsigned int inputBandIndex1, const te::rst::Raster &inputRaster2, const unsigned int inputBandIndex2, const unsigned int maxThreads, double const *const mean1ValuePtr, double const *const mean2ValuePtr, double &covarianceValue)
Get the covariance of band pixel values.
te::rp::FeederConstRaster
Feeder from a input rasters.
Definition: FeedersRaster.h:47
Matrix.h
Generic template matrix.
te::gm::GeometryCollection::add
void add(Geometry *g)
It adds the geometry into the collection.
te::rp::SaveSensorParams
TERPEXPORT void SaveSensorParams(std::map< std::string, SpectralSensorParams > &)
Saves in SpectralSensor.json file the spectral sensors parameters.
te::rp::DirectPrincipalComponents
TERPEXPORT bool DirectPrincipalComponents(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, boost::numeric::ublas::matrix< double > &pcaMatrix, te::rst::Raster &pcaRaster, const std::vector< unsigned int > &pcaRasterBands, const unsigned int maxThreads)
Generate all principal components from the given input raster.
te::rp::DecomposeBands
TERPEXPORT bool DecomposeBands(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< std::map< std::string, std::string > > &outputRastersInfos, const std::string &outputDataSourceType, std::vector< boost::shared_ptr< te::rst::Raster > > &outputRastersPtrs)
Decompose a multi-band raster into a set of one-band rasters.
te::rp::ConvertIHS2RGB
TERPEXPORT bool ConvertIHS2RGB(const te::rst::Raster &inputIHSRaster, const unsigned int intensityBandIdx, const unsigned int hueBandIdx, const unsigned int saturationBandIdx, const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster &outputRGBRaster)
IHS to RGB conversion.
te::rp::GetMeanValue
TERPEXPORT bool GetMeanValue(const te::rst::Raster &inputRaster, const unsigned int inputBandIndex, const unsigned int maxThreads, double &meanValue)
Get the mean of band pixel values.
te::gm::Surface
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:55
te::rp::SpectralSensorParams::m_upper
double m_upper
Definition: Functions.h:95
te::rp::TriangleWAFilter
@ TriangleWAFilter
Triangle filter type.
Definition: Functions.h:78
te::rp::ConvertRGB2IHS
TERPEXPORT bool ConvertRGB2IHS(const te::rst::Raster &inputRGBRaster, const unsigned int redBandIdx, const unsigned int greenBandIdx, const unsigned int blueBandIdx, const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster &outputIHSRaster)
RGB to IHS conversion.
te::rp::ConvertHLS2RGB
TERPEXPORT bool ConvertHLS2RGB(const te::rst::Raster &inputHLSRaster, const unsigned int hueBandIdx, const unsigned int lightBandIdx, const unsigned int saturationBandIdx, const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster &outputRGBRaster)
HLS to RGB conversion.
te::rp::GetDigitalNumberBandInfo
TERPEXPORT std::pair< double, double > GetDigitalNumberBandInfo(std::string bandName)
Returns the maximun and minimum digital numbers of a given sensor/band.
te::dt::UCHAR_TYPE
@ UCHAR_TYPE
Definition: Enums.h:189
te::rp::CreateRasterFileFromMatrix
bool CreateRasterFileFromMatrix(const te::rp::Matrix< MatrixElementT > &matrix, const bool normalize, const std::string &fileName)
Create a tiff file from a matrix.
Definition: Functions.h:255
te::rp::GetDigitalNumberBandMin
TERPEXPORT double GetDigitalNumberBandMin(std::string bandName)
Returns the minimum digital number of a given sensor/band.
te::rp::Copy2DiskRaster
bool TERPEXPORT Copy2DiskRaster(const te::rst::Raster &inputRaster, const std::string &fileName)
Create a new raster into a GDAL datasource.
te::rp::GetSpectralBandMax
TERPEXPORT double GetSpectralBandMax(std::string bandName)
Returns the maximum reflectance value of a given sensor/band.
te::rst::Grid
A rectified grid is the spatial support for raster data.
Definition: Grid.h:69
FeedersRaster.h
Raster objects feeders.
te::gm::Geometry::convexHull
virtual Geometry * convexHull() const _NOEXCEPT_OP(false)
This method calculates the Convex Hull of a geometry.
te::rp::SpectralSensorParams::SpectralSensorParams
SpectralSensorParams()
Definition: Functions.h:83
te::rst::RasterFactory::make
static Raster * make()
It creates and returns an empty raster with default raster driver.
te::rp::RemapValues
TERPEXPORT bool RemapValues(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const boost::numeric::ublas::matrix< double > &remapMatrix, te::rst::Raster &outputRaster, const std::vector< unsigned int > &outputRasterBands, const unsigned int maxThreads)
Remap pixel values using a remap function matrix.
te::rp::getJointHistogramStats
TERPEXPORT bool getJointHistogramStats(const std::map< std::pair< double, double >, unsigned int > &jointHistogram, const std::map< double, unsigned int > &histogram1, const std::map< double, unsigned int > &histogram2, double &covariance)
Compute statiscts from the given histogram.
te::rp::NormalizeRaster
TERPEXPORT bool NormalizeRaster(te::rst::Raster &inputRaster, double nmin=0.0, double nmax=255.0)
Normalizes one raster in a given interval.
te::rp::InverseWaveletAtrous
TERPEXPORT bool InverseWaveletAtrous(const te::rst::Raster &waveletRaster, const unsigned int levelsNumber, te::rst::Raster &outputRaster, const std::vector< unsigned int > &outputRasterBands)
Regenerate the original raster from its wavelets planes.
te::rp::WaveletAtrousFilterType
WaveletAtrousFilterType
Wavelet Atrous Filter types.
Definition: Functions.h:75
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
te::rp::ComposeBands
TERPEXPORT bool ComposeBands(te::rp::FeederConstRaster &feeder, const std::vector< unsigned int > &inputRasterBands, const te::rst::Interpolator::Method &interpMethod, const std::map< std::string, std::string > &outputRasterInfo, const std::string &outputDataSourceType, const unsigned int maxThreads, std::unique_ptr< te::rst::Raster > &outputRasterPtr)
Compose a set of bands into one multi-band raster.
te::rp::DirectWaveletAtrous
TERPEXPORT bool DirectWaveletAtrous(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, te::rst::Raster &waveletRaster, const unsigned int levelsNumber, const boost::numeric::ublas::matrix< double > &filter)
Generate all wavelet planes from the given input raster.
te::rp::getHistogramStats
TERPEXPORT void getHistogramStats(const std::map< double, unsigned int > &histogram, double &min, double &max, double &mean, double &stdDev, double &mode, double &entropy, double &sum, double &sum2, double &sum3, double &sum4, double &variance, double &median)
Compute statiscts from the given histogram.
te::rp::getSensorParams
TERPEXPORT std::map< std::string, SpectralSensorParams > getSensorParams()
Returns a map with spectral sensors parameters defined in SpectralSensor.json file.
te::rst::PolygonIterator::IterationType
IterationType
Definition: PositionIterator.h:162
te::rp::GetDetailedExtent
TERPEXPORT bool GetDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &detailedExtent)
Create a datailed extent from the given grid.
te::rp::SpectralSensorParams::m_band
int m_band
Definition: Functions.h:93
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::Matrix::getColumnsNumber
unsigned int getColumnsNumber() const
The number of current matrix columns.
Definition: Matrix.h:798
te::rp::CreateNewRaster
bool TERPEXPORT CreateNewRaster(const te::rst::Grid &rasterGrid, const std::vector< te::rst::BandProperty * > &bandsProperties, const std::string &outDataSetName, const std::string &dataSourceType, RasterHandler &outRasterHandler)
Create a new raster into the givem data source.
te::rp::Convert2DoublesVector
void TERPEXPORT Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements.
te::rp::CreateWaveletAtrousFilter
TERPEXPORT boost::numeric::ublas::matrix< double > CreateWaveletAtrousFilter(const WaveletAtrousFilterType &filterType)
Create a Wavele Atrous Filter.
te::rp::SpectralSensorParams::m_lower
double m_lower
Definition: Functions.h:94
te::rst::BandProperty
A raster band description.
Definition: BandProperty.h:62
te::rp::ConvertRGB2HLS
TERPEXPORT bool ConvertRGB2HLS(const te::rst::Raster &inputRGBRaster, const unsigned int redBandIdx, const unsigned int greenBandIdx, const unsigned int blueBandIdx, const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster &outputHLSRaster)
RGB to HLS conversion.
te::rp::GetIndexedDetailedExtent
TERPEXPORT bool GetIndexedDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &indexedDetailedExtent)
Create a indexed (lines,columns) datailed extent from the given grid.
te::rp::InversePrincipalComponents
TERPEXPORT bool InversePrincipalComponents(const te::rst::Raster &pcaRaster, const boost::numeric::ublas::matrix< double > &pcaMatrix, te::rst::Raster &outputRaster, const std::vector< unsigned int > &outputRasterBands, const unsigned int maxThreads)
Regenerate the original raster from its principal components.
TERP_TRUE_OR_RETURN_FALSE
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
Definition: Macros.h:185
te::rp::GetSpectralBandMin
TERPEXPORT double GetSpectralBandMin(std::string bandName)
Returns the minimum reflectance value of a given sensor/band.
te::rp::getJointHistograms
TERPEXPORT bool getJointHistograms(const te::rst::Raster &raster, const unsigned int bandIndex1, const unsigned int bandIndex2, const std::vector< te::gm::Polygon const * > &rois, const unsigned int histoBins, const unsigned int maxThreads, const te::rst::PolygonIterator< double >::IterationType roisItType, std::map< std::pair< double, double >, unsigned int > &realJointHistogram, std::map< std::pair< double, double >, unsigned int > &imagJointHistogram, std::map< double, unsigned int > const *const rasterRealHistogram1ptr, std::map< double, unsigned int > const *const rasterImagHistogram1Ptr, std::map< double, unsigned int > const *const rasterRealHistogram2Ptr, std::map< double, unsigned int > const *const rasterImagHistogram2Ptr)
Compute and return the joint histogram of occurring values (real and imaginary) inside defined region...
te::da::DataSource
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
te::rp::SpectralSensorParams
Definition: Functions.h:82
te::rp::GetSpectralBandInfo
TERPEXPORT SpectralSensorParams GetSpectralBandInfo(std::string bandName)
Returns the maximun and minimum reflectance values of a given sensor/band.
te::rp::InvalidWAFilter
@ InvalidWAFilter
Invalid filter type.
Definition: Functions.h:76
te::rp::CreateNewGdalRaster
bool TERPEXPORT CreateNewGdalRaster(const te::rst::Grid &rasterGrid, std::vector< te::rst::BandProperty * > bandsProperties, const std::string &fileName, RasterHandler &outRasterHandler)
Create a new raster into a GDAL datasource.
te::rp::getHistograms
TERPEXPORT bool getHistograms(const te::rst::Raster &raster, const unsigned int bandIndex, const std::vector< te::gm::Polygon const * > &rois, const unsigned int histoBins, const unsigned int maxThreads, const te::rst::PolygonIterator< double >::IterationType roisItType, std::map< double, unsigned > &rHistogram, std::map< double, unsigned > &iHistogram)
Compute and return the histogram soccurring values (real and imaginary) inside defined regions of int...
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::rp::ReplaceContiguousSegmentValues
TERPEXPORT bool ReplaceContiguousSegmentValues(te::rst::Raster &inputRaster, const unsigned int &inputRasterBandIdx, const unsigned targetRow, const unsigned targetCol, const double &outputValue)
Replace a contiguos segment pixel values.
te::rp::SpectralSensorParams::m_min
double m_min
Definition: Functions.h:96
te::rp::GetStdDevValue
TERPEXPORT bool GetStdDevValue(const te::rst::Raster &inputRaster, const unsigned int inputBandIndex, const unsigned int maxThreads, double const *const meanValuePtr, double &stdDevValue)
Get the standard deviation of band pixel values.
te::gm::LinearRing
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:54
RasterHandler.h
Raster tuple.
te::rp::Matrix::getLinesNumber
unsigned int getLinesNumber() const
The number of current matrix lines.
Definition: Matrix.h:791
te::sa::Grid
@ Grid
Definition: Enums.h:106
te::rp::ConvertDoublesVector
void TERPEXPORT ConvertDoublesVector(double *inputVector, unsigned int inputVectorSize, const int outputVectorDataType, void *outputVector)
Convert a doubles vector.
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51
te::rp::GetSensorFilename
TERPEXPORT std::string GetSensorFilename()
Returns a json filename with spectral sensors parameters.