Loading...
Searching...
No Matches
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
60namespace 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 = 0, //!< Invalid filter type
77 B3SplineWAFilter = 1, //!< Spline filter type.
78 TriangleWAFilter = 2 //!< 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 */
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 try
274 {
275 outputRasterPtr.reset(
276 te::rst::RasterFactory::make( "GDAL", newgrid, bandsProperties, rInfo, 0, 0));
277 }
278 catch(...)
279 {
280 outputRasterPtr.reset();
281 }
282 TERP_TRUE_OR_RETURN_FALSE( outputRasterPtr.get(), "Output raster creation error");
283
284 unsigned int line = 0;
285 unsigned int col = 0;
286 const unsigned int nLines = matrix.getLinesNumber();
287 const unsigned int nCols = matrix.getColumnsNumber();
288 MatrixElementT matrixValue = 0;
289
290 MatrixElementT gain = 1.0;
291 MatrixElementT offset = 0.0;
292 if( normalize )
293 {
294 MatrixElementT matrixValueMin = std::numeric_limits< MatrixElementT >::max();
295 MatrixElementT matrixValueMax = -1.0 * matrixValueMin;
296 for( line = 0 ; line < nLines ; ++line )
297 {
298 for( col = 0 ; col < nCols ; ++col )
299 {
300 matrixValue = matrix[ line ][ col ];
301 if( matrixValue < matrixValueMin )
302 matrixValueMin = matrixValue;
303 if( matrixValue > matrixValueMax )
304 matrixValueMax = matrixValue;
305 }
306 }
307
308 if( matrixValueMax == matrixValueMin )
309 {
310 gain = 0.0;
311 offset = 0.0;
312 }
313 else
314 {
315 gain = 255.0 / ( matrixValueMax - matrixValueMin );
316 offset = -1.0 * ( matrixValueMin );
317 }
318 }
319
320 const MatrixElementT min0 = 0;
321 const MatrixElementT max255 = 255;
322
323 for( line = 0 ; line < nLines ; ++line )
324 {
325 for( col = 0 ; col < nCols ; ++col )
326 {
327 matrixValue = matrix[ line ][ col ];
328
329 if( normalize )
330 {
331 matrixValue += offset;
332 matrixValue *= gain;
333 matrixValue = std::max( min0, matrixValue );
334 matrixValue = std::min( max255, matrixValue );
335 }
336
337 outputRasterPtr->setValue( col, line, static_cast<double>(matrixValue), 0 );
338 }
339 }
340
341 return true;
342 }
343
344 /*!
345 \brief Returns a json filename with spectral sensors parameters.
346 \ingroup rp_func
347 */
349
350 /*!
351 \brief Returns a vector os with band's names.
352 \ingroup rp_func
353 */
354 TERPEXPORT std::vector<std::string> GetBandNames();
355
356 /*!
357 \brief Returns a map with spectral sensors parameters defined in SpectralSensor.json file.
358 \ingroup rp_func
359 */
360 TERPEXPORT std::map<std::string, SpectralSensorParams > getSensorParams();
361
362 /*!
363 \brief Saves in SpectralSensor.json file the spectral sensors parameters.
364 \ingroup rp_func
365 */
366 TERPEXPORT void SaveSensorParams(std::map<std::string, SpectralSensorParams > &);
367
368 /*!
369 \brief Get the maximun and minimum reflectance values of a given sensor/band.
370 \param specBandInfo The requested band info.
371 \return true if the requested band name was found, false if not.
372 \ingroup rp_func
373 */
374 TERPEXPORT bool GetSpectralBandInfo(const std::string& bandName,
375 SpectralSensorParams& specBandInfo );
376
377 /*!
378 \brief Get all spectral band infos.
379 \param specBandInfos The requested bands infos.
380 \ingroup rp_func
381 */
383 std::map<std::string, struct SpectralSensorParams >& specBandInfos );
384
385 /*!
386 \brief Returns the minimum reflectance value of a given sensor/band.
387 \ingroup rp_func
388 */
389 TERPEXPORT double GetSpectralBandMin(std::string bandName);
390
391 /*!
392 \brief Returns the maximum reflectance value of a given sensor/band.
393 \ingroup rp_func
394 */
395 TERPEXPORT double GetSpectralBandMax(std::string bandName);
396
397 /*!
398 \brief Returns the maximun and minimum digital numbers of a given sensor/band.
399 \ingroup rp_func
400 */
401 TERPEXPORT std::pair<double, double> GetDigitalNumberBandInfo(std::string bandName);
402
403 /*!
404 \brief Returns the maximum digital number of a given sensor/band.
405 \ingroup rp_func
406 */
407 TERPEXPORT double GetDigitalNumberBandMax(std::string bandName);
408
409 /*!
410 \brief Returns the minimum digital number of a given sensor/band.
411 \ingroup rp_func
412 */
413 TERPEXPORT double GetDigitalNumberBandMin(std::string bandName);
414
415 /*!
416 \brief Normalizes one raster in a given interval.
417
418 \param inputRaster The given raster.
419 \param nmin The new minimum value (default = 0.0).
420 \param nmax The new maximum value (default = 255.0).
421
422 \return true if normalization occurs and false otherwise.
423 \ingroup rp_func
424 */
425 TERPEXPORT bool NormalizeRaster(te::rst::Raster& inputRaster, double nmin = 0.0, double nmax = 255.0);
426
427 /*!
428 \brief Normalizes a raster in a given interval.
429
430 \param inputRaster The given raster.
431
432 \return a raster normalized or null pointer on errors.
433 \ingroup rp_func
434 */
436
437 /*!
438 \brief RGB to IHS conversion.
439 \param inputRGBRaster The input raster.
440 \param redBandIdx The red band index.
441 \param greenBandIdx The red band index.
442 \param blueBandIdx The red band index.
443 \param rgbRangeMin The minimum RGB value.
444 \param rgbRangeMax The maximum RGB value.
445 \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).
446 \return true if OK, false on errors.
447 \note The outputIHSRaster mas have a float or double data type.
448 \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
449 \ingroup rp_func
450 */
451 TERPEXPORT bool ConvertRGB2IHS( const te::rst::Raster& inputRGBRaster,
452 const unsigned int redBandIdx, const unsigned int greenBandIdx,
453 const unsigned int blueBandIdx, const double rgbRangeMin,
454 const double rgbRangeMax, te::rst::Raster& outputIHSRaster );
455
456 /*!
457 \brief RGB to IHS conversion.
458 \param inputRedRaster The input red raster.
459 \param redBandIdx The red band index.
460 \param inputGreenRaster The input green raster.
461 \param greenBandIdx The green band index.
462 \param inputBlueRaster The input blue raster.
463 \param blueBandIdx The blue band index.
464 \param rgbRangeMin The minimum RGB value.
465 \param rgbRangeMax The maximum RGB value.
466 \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).
467 \return true if OK, false on errors.
468 \note The outputIHSRaster mas have a float or double data type.
469 \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
470 \ingroup rp_func
471 */
472 TERPEXPORT bool ConvertRGB2IHS(const te::rst::Raster& inputRedRaster, const unsigned int redBandIdx,
473 const te::rst::Raster& inputGreenRaster, const unsigned int greenBandIdx,
474 const te::rst::Raster& inputBlueRaster, const unsigned int blueBandIdx,
475 const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputIHSRaster);
476
477 /*!
478 \brief IHS to RGB conversion.
479 \param inputIHSRaster The input raster.
480 \param intensityBandIdx The intensity band index.
481 \param hueBandIdx The hue band index.
482 \param saturationBandIdx The saturation band index.
483 \param rgbRangeMin The minimum RGB value.
484 \param rgbRangeMax The maximum RGB value.
485 \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputIHSRaster) where the RGB data will be written.
486 \return true if OK, false on errors.
487 \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
488 \ingroup rp_func
489 */
490 TERPEXPORT bool ConvertIHS2RGB( const te::rst::Raster& inputIHSRaster,
491 const unsigned int intensityBandIdx, const unsigned int hueBandIdx,
492 const unsigned int saturationBandIdx, const double rgbRangeMin,
493 const double rgbRangeMax, te::rst::Raster& outputRGBRaster );
494
495 /*!
496 \brief IHS to RGB conversion.
497 \param inputIRaster The input intensity raster.
498 \param intensityBandIdx The intensity band index.
499 \param inputHRaster The input hue raster.
500 \param hueBandIdx The hue band index.
501 \param inputSRaster The input saturation raster.
502 \param saturationBandIdx The saturation band index.
503 \param rgbRangeMin The minimum RGB value.
504 \param rgbRangeMax The maximum RGB value.
505 \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputIHSRaster) where the RGB data will be written.
506 \return true if OK, false on errors.
507 \note IHS data with the following channels ranges: I:[0,1] H:[0,2pi] (radians) S:[0,1].
508 \ingroup rp_func
509 */
510 TERPEXPORT bool ConvertIHS2RGB(const te::rst::Raster& inputIRaster, const unsigned int intensityBandIdx,
511 const te::rst::Raster& inputHRaster, const unsigned int hueBandIdx,
512 const te::rst::Raster& inputSRaster, const unsigned int saturationBandIdx,
513 const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputRGBRaster);
514
515 /*!
516 \brief RGB to HLS conversion.
517 \param inputRGBRaster The input raster.
518 \param redBandIdx The red band index.
519 \param greenBandIdx The red band index.
520 \param blueBandIdx The red band index.
521 \param rgbRangeMin The minimum RGB value.
522 \param rgbRangeMax The maximum RGB value.
523 \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).
524 \return true if OK, false on errors.
525 \note The outputHLSRaster mas have a float or double data type.
526 \ingroup rp_func
527 */
528 TERPEXPORT bool ConvertRGB2HLS(const te::rst::Raster& inputRGBRaster,
529 const unsigned int redBandIdx, const unsigned int greenBandIdx,
530 const unsigned int blueBandIdx, const double rgbRangeMin,
531 const double rgbRangeMax, te::rst::Raster& outputHLSRaster);
532
533 /*!
534 \brief RGB to HLS conversion.
535 \param inputRedRaster The input red raster.
536 \param redBandIdx The red band index.
537 \param inputGreenRaster The input green raster.
538 \param greenBandIdx The green band index.
539 \param inputBlueRaster The input blue raster.
540 \param blueBandIdx The blue band index.
541 \param rgbRangeMin The minimum RGB value.
542 \param rgbRangeMax The maximum RGB value.
543 \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).
544 \return true if OK, false on errors.
545 \note The outputHLSRaster mas have a float or double data type.
546 \ingroup rp_func
547 */
548 TERPEXPORT bool ConvertRGB2HLS(const te::rst::Raster& inputRedRaster, const unsigned int redBandIdx,
549 const te::rst::Raster& inputGreenRaster, const unsigned int greenBandIdx,
550 const te::rst::Raster& inputBlueRaster, const unsigned int blueBandIdx,
551 const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputHLSRaster);
552
553 /*!
554 \brief HLS to RGB conversion.
555 \param inputHLSRaster The input raster.
556 \param hueBandIdx The hue band index.
557 \param lightBandIdx The light band index.
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& inputHLSRaster,
566 const unsigned int hueBandIdx, const unsigned int lightBandIdx,
567 const unsigned int saturationBandIdx, const double rgbRangeMin,
568 const double rgbRangeMax, te::rst::Raster& outputRGBRaster);
569
570 /*!
571 \brief HLS to RGB conversion.
572 \param inputHRaster The input hue raster.
573 \param hueBandIdx The hue band index.
574 \param inputLRaster The input light raster.
575 \param lightBandIdx The light band index.
576 \param inputSRaster The input saturation raster.
577 \param saturationBandIdx The saturation band index.
578 \param rgbRangeMin The minimum RGB value.
579 \param rgbRangeMax The maximum RGB value.
580 \param outputRGBRaster An output pré-initiated raster (with the same dimensions of inputHLSRaster) where the RGB data will be written.
581 \return true if OK, false on errors.
582 \ingroup rp_func
583 */
584 TERPEXPORT bool ConvertHLS2RGB(const te::rst::Raster& inputHRaster, const unsigned int hueBandIdx,
585 const te::rst::Raster& inputLRaster, const unsigned int lightBandIdx,
586 const te::rst::Raster& inputSRaster, const unsigned int saturationBandIdx,
587 const double rgbRangeMin, const double rgbRangeMax, te::rst::Raster& outputRGBRaster);
588
589 /*!
590 \brief Get the mean of band pixel values.
591 \param inputRaster The input raster.
592 \param inputBandIndex Input band index.
593 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
594 \param forceNoDataValue Ignore the raster original band no-data value and use the value given by the parameter noDataValue.
595 \param noDataValue The no-data value to be used insted of the original raster band no-data value.
596 \param meanValue The calculated mean value.
597 \return true if OK, false on errors.
598 \note Optimized for rasters where the used bands have the same blocking scheme.
599 \ingroup rp_func
600 */
602 const te::rst::Raster& inputRaster,
603 const unsigned int inputBandIndex,
604 const unsigned int maxThreads,
605 const bool forceNoDataValue,
606 const double noDataValue,
607 double& meanValue );
608
609 /*!
610 \brief Get the standard deviation of band pixel values.
611 \param inputRaster The input raster.
612 \param inputBandIndex Input band index.
613 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
614 \param forceNoDataValue Ignore the raster original band no-data value and use the value given by the parameter noDataValue.
615 \param noDataValue The no-data value to be used insted of the original raster band no-data value.
616 \param meanValuePtr A pointer to a pre-calculated band mean value or zero if it does not exist.
617 \param stdDevValue The calculated standard deviation value.
618 \return true if OK, false on errors.
619 \note Optimized for rasters where the used bands have the same blocking scheme.
620 \ingroup rp_func
621 */
623 const te::rst::Raster& inputRaster,
624 const unsigned int inputBandIndex,
625 const unsigned int maxThreads,
626 const bool forceNoDataValue,
627 const double noDataValue,
628 double const * const meanValuePtr,
629 double& stdDevValue );
630
631 /*!
632 \brief Get the covariance of band pixel values.
633 \param inputRaster1 The input raster 1.
634 \param inputBandIndex1 Input raster 1 band index.
635 \param inputRaster2 The input raster 2.
636 \param inputBandIndex2 Input raster 2 band index.
637 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
638 \param mean1ValuePtr A pointer to a pre-calculated band1 mean value or zero if it does not exist.
639 \param mean2ValuePtr A pointer to a pre-calculated band2 mean value or zero if it does not exist.
640 \param covarianceValue The calculated covariance value.
641 \return true if OK, false on errors.
642 \ingroup rp_func
643 */
645 const te::rst::Raster& inputRaster1,
646 const unsigned int inputBandIndex1,
647 const te::rst::Raster& inputRaster2,
648 const unsigned int inputBandIndex2,
649 const unsigned int maxThreads,
650 double const * const mean1ValuePtr,
651 double const * const mean2ValuePtr,
652 double& covarianceValue );
653
654 /*!
655 \brief Generate all principal components from the given input raster.
656 \param inputRaster Input raster.
657 \param inputRasterBands Input raster bands.
658 \param pcaMatrix An input PCA valid matrix or an empty matrix (will be calculated over the principal components process).
659 \param pcaRaster The pré-initiated output PCA raster (with the same dimensions of inputRaster) and double as the data type.
660 \param pcaRasterBands Output raster bands.
661 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
662 \return true if OK, false on errors.
663 \note Optimized for rasters where the used bands have the same blocking scheme.
664 \ingroup rp_func
665 */
667 const te::rst::Raster& inputRaster,
668 const std::vector< unsigned int >& inputRasterBands,
669 boost::numeric::ublas::matrix< double >& pcaMatrix,
670 te::rst::Raster& pcaRaster,
671 const std::vector< unsigned int >& pcaRasterBands,
672 const unsigned int maxThreads );
673
674 /*!
675 \brief Regenerate the original raster from its principal components.
676 \param pcaRaster The principal components raster (with the same dimensions of outputRaster).
677 \param pcaMatrix The matrix generated by the direct principal components process.
678 \param outputRaster The regenerated output raster (with the same dimentions.
679 \param outputRasterBands Output raster bands.
680 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
681 \return true if OK, false on errors.
682 \note Optimized for rasters where the used bands have the same blocking scheme.
683 \ingroup rp_func
684 */
686 const te::rst::Raster& pcaRaster,
687 const boost::numeric::ublas::matrix< double >& pcaMatrix,
688 te::rst::Raster& outputRaster,
689 const std::vector< unsigned int >& outputRasterBands,
690 const unsigned int maxThreads );
691
692 /*!
693 \brief Remap all pixel values using a user supplied target values (non-target values are just copied from input to output).
694 \param inputRaster Input raster.
695 \param inputRasterBandIdx Input raster band.
696 \param targetValues A vector of target values pairs in the form: std::pair< old_value, new_value >.
697 \param enableProgress Enable/disable the progress interface.
698 \param restrictionPols A vector of polygons where the remap must be executed or an empty vector indicating all pixels must be remapped.
699 \param outputRaster The pré-initiated output raster.
700 \param outputRasterBandIdx Output raster band.
701 \return true if OK, false on errors.
702 \note Optimized for rasters where the used bands have the same blocking scheme.
703 \ingroup rp_func
704 */
706 const te::rst::Raster& inputRaster,
707 const unsigned int& inputRasterBandIdx,
708 const std::vector< std::pair< double, double > >& targetValues,
709 const bool enableProgress,
710 const std::vector< te::gm::Polygon* >& restrictionPols,
711 te::rst::Raster& outputRaster,
712 const unsigned int& outputRasterBandIdx );
713
714 /*!
715 \brief Remap pixel values using a remap function matrix.
716 \param inputRaster Input raster.
717 \param inputRasterBands Input raster bands.
718 \param remapMatrix The remap function matrix.
719 \param outputRaster The pré-initiated output raster (with the same dimentions of inputRaster).
720 \param outputRasterBands Output raster bands.
721 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
722 \return true if OK, false on errors.
723 \note Optimized for rasters where the used bands have the same blocking scheme.
724 \ingroup rp_func
725 */
727 const te::rst::Raster& inputRaster,
728 const std::vector< unsigned int >& inputRasterBands,
729 const boost::numeric::ublas::matrix< double >& remapMatrix,
730 te::rst::Raster& outputRaster,
731 const std::vector< unsigned int >& outputRasterBands,
732 const unsigned int maxThreads );
733
734 /*!
735 \brief Decompose a multi-band raster into a set of one-band rasters.
736 \param inputRaster Input raster.
737 \param inputRasterBands Input raster bands.
738 \param outputRastersInfos Output rasters connections infos. (one info for each decomposed band).
739 \param outputDataSourceType Output raster datasource type.
740 \param outputRastersPtrs Pointers to the generated outputs rasters.
741 \return true if OK, false on errors.
742 \ingroup rp_func
743 */
745 const te::rst::Raster& inputRaster,
746 const std::vector< unsigned int >& inputRasterBands,
747 const std::vector< std::map<std::string, std::string> > & outputRastersInfos,
748 const std::string& outputDataSourceType,
749 std::vector< boost::shared_ptr< te::rst::Raster > > & outputRastersPtrs );
750
751 /*!
752 \brief Compose a set of bands into one multi-band raster.
753 \param inputRasters Input rasters.
754 \param inputRasterBands Input raster bands (one band for each input raster).
755 \param interpMethod The interpolator method to use.
756 \param outputRasterInfo Output raster connection info.
757 \param outputDataSourceType Output raster datasource type.
758 \param maxThreads The maximum number of threads to use (0-auto, 1-single thread used).
759 \param outputRasterPtr A pointer to the generated output raster.
760 \param allowNoDataPixels If disabled only pixels with valid data on all bands will be written to the output raster.
761 \param enableProgress Enable/disable the progress interface.
762 \return true if OK, false on errors.
763 \note The first raster Grid will be taken as reference for the composed raster.
764 \ingroup rp_func
765 */
767 const std::vector< te::rst::Raster const * >& inputRasters,
768 const std::vector< unsigned int >& inputRasterBands,
769 const te::rst::Interpolator::Method& interpMethod,
770 const std::map<std::string, std::string>& outputRasterInfo,
771 const std::string& outputDataSourceType,
772 const unsigned int maxThreads,
773 const bool allowNoDataPixels,
774 const bool enableProgress,
775 std::unique_ptr< te::rst::Raster >& outputRasterPtr );
776
777 /*!
778 \brief Create a datailed extent from the given grid.
779 \param grid Input grid.
780 \param detailedExtent The created detailed extent.
781 \return true if ok, false on errors.
782 \ingroup rp_func
783 */
785 te::gm::LinearRing& detailedExtent );
786
787 /*!
788 \brief Create a indexed (lines,columns) datailed extent from the given grid.
789 \param grid Input grid.
790 \param indexedDetailedExtent The created detailed extent.
791 \return true if ok, false on errors.
792 \ingroup rp_func
793 */
795 te::gm::LinearRing& indexedDetailedExtent );
796
797 /*!
798 \brief Create a Wavele Atrous Filter.
799 \param filterType The filter type.
800 \return the created filter.
801 \ingroup rp_func
802 */
803 TERPEXPORT boost::numeric::ublas::matrix< double >
805
806 /*!
807 \brief Generate all wavelet planes from the given input raster.
808 \param inputRaster Input raster.
809 \param inputRasterBands Input raster bands.
810 \param waveletRaster The pré-initiated output wavelet raster (with the same dimensions of inputRaster) and double as the data type.
811 \param levelsNumber The number of decomposed wavelet levels to generate for each input raster band;
812 \param filter The square filter to use.
813 \return true if OK, false on errors.
814 \note The band order of the generated wavelet levels: { [ band0-smoothed0, band0-wavelet0, ... , band0-smoothedN, band0-waveletN ], ... }
815 \note The number of bands of waveletRaster must be ( inputRasterBands.size() * 2 * levelsNumber ) at least.
816 \ingroup rp_func
817 */
819 const te::rst::Raster& inputRaster,
820 const std::vector< unsigned int >& inputRasterBands,
821 te::rst::Raster& waveletRaster,
822 const unsigned int levelsNumber,
823 const boost::numeric::ublas::matrix< double >& filter );
824
825 /*!
826 \brief Regenerate the original raster from its wavelets planes.
827 \param waveletRaster The input wavelet raster (with the same dimensions of outputRaster).
828 \param levelsNumber The number of decomposed wavelet levels present inside the wavelet raster.
829 \param outputRaster The regenerated output raster.
830 \param outputRasterBands Output raster bands.
831 \return true if OK, false on errors.
832 \note The band order of the expected wavelet levels: { [ band0-smoothed0, band0-wavelet0, ... , band0-smoothedN, band0-waveletN ], ... }
833 \note The number of bands of waveletRaster must be ( outputRasterBands.size() * 2 * levelsNumber ) at least.
834 \note Only the wavelet bands and the last smoothed band are used.
835 \ingroup rp_func
836 */
838 const te::rst::Raster& waveletRaster,
839 const unsigned int levelsNumber,
840 te::rst::Raster& outputRaster,
841 const std::vector< unsigned int >& outputRasterBands );
842
843 /*!
844 \brief Resample a subset of the raster, given a box.
845 \param inputRaster Input raster.
846 \param inputRasterBands Input raster bands to process.
847 \param interpMethod The method of interpolation. \sa te::rst::Interpolator
848 \param interpWindowRadius Interpolator windows radius around the target pixel (when applicable).
849 \param firstRow The starting row to make a subset of the image.
850 \param firstColumn The starting column to make a subset of the image.
851 \param height The height of the subset.
852 \param width The width of the subset.
853 \param newheight The resampled height of the new raster.
854 \param newwidth The resampled width of the new raster.
855 \param rinfo The parameters needed to build the output raster (see RasterFactory documentation).
856 \param dataSourceType Data source type (raster type. I.E. GDAL).
857 \param resampledRasterPtr The resampled raster pointer.
858 \return true if ok, false on errors.
859 \ingroup rp_func
860 */
862 const te::rst::Raster& inputRaster,
863 const std::vector< unsigned int >& inputRasterBands,
864 const te::rst::Interpolator::Method interpMethod,
865 const unsigned int interpWindowRadius,
866 const unsigned int firstRow,
867 const unsigned int firstColumn,
868 const unsigned int height,
869 const unsigned int width,
870 const unsigned int newheight,
871 const unsigned int newwidth,
872 const std::map<std::string, std::string>& rinfo,
873 const std::string& dataSourceType,
874 std::unique_ptr< te::rst::Raster >& resampledRasterPtr );
875
876 /*!
877 \brief Returns the tie points converx hull area.
878 \param tiePoints Input tie-points (container of te::gm::GTParameters::TiePoint).
879 \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.
880 \return Returns the tie points converx hull area.
881 \ingroup rp_func
882 */
883 template< typename ContainerT >
884 double GetTPConvexHullArea( const ContainerT& tiePoints,
885 const bool useTPSecondCoordPair )
886 {
887 if( tiePoints.size() < 3 )
888 {
889 return 0;
890 }
891 else
892 {
894
895 typename ContainerT::const_iterator it =
896 tiePoints.begin();
897 const typename ContainerT::const_iterator itE =
898 tiePoints.end();
899
900 while( it != itE )
901 {
902 if( useTPSecondCoordPair )
903 points.add(new te::gm::Point(it->second.x, it->second.y));
904 else
905 points.add(new te::gm::Point(it->first.x, it->first.y));
906
907 ++it;
908 }
909
910 std::unique_ptr< te::gm::Geometry > convexHullPolPtr( points.convexHull() );
911
912 if( dynamic_cast< te::gm::Surface* >( convexHullPolPtr.get() ) )
913 {
914 return ( (te::gm::Surface*)( convexHullPolPtr.get() ) )->getArea();
915 }
916 else
917 {
918 return 0.0;
919 }
920 }
921 }
922
923 /*!
924 \brief Create a fixed step sequential color palette.
925 \param paletteSize The desired palette size.
926 \param palette The crated palette.
927 \ingroup rp_func
928 */
930 const unsigned int paletteSize,
931 const bool randomize,
932 std::vector< te::rst::BandProperty::ColorEntry >& palette );
933
934 /*!
935 \brief Create a new raster grouping pixel values following the number of slices and/or slice limits.
936 \param inputRaster Input raster.
937 \param inputRasterBand Input raster band.
938 \param createPaletteRaster If true a paletted raster will be created instead of a multi-band raster..
939 \param slicesNumber The number of histogram slices to create;
940 \param eqHistogram If true, the input raster will be equalized before the slicing process.
941 \param rasterInfo The output raster info (specific driver info).
942 \param rasterType The output raster type (specific driver name - See te::rst::RasterFactory dictorary for more info).
943 \param enableProgress Enable/disable the progress interface.
944 \param palettePtr A pointer to an optional user given palette (if null, an fixed step pallete will be generated).
945 \param outRasterPtr The output sliced raster pointer.
946 \param slicesLimitsPtr A null pointer or a pointer to a container of slice limits ( the small of the the values for each slice range ).
947 \param slicesOutputValuesPtr A null pointer or a pointer to a vector of output raster values related to each slice.
948 \return true if OK, false on errors.
949 \ingroup rp_func
950 */
952 const te::rst::Raster& inputRaster,
953 const unsigned int inputRasterBand,
954 const bool createPaletteRaster,
955 const unsigned int slicesNumber,
956 const bool eqHistogram,
957 const std::map< std::string, std::string >& rasterInfo,
958 const std::string& rasterType,
959 const bool enableProgress,
960 std::vector< te::rst::BandProperty::ColorEntry > const * const palettePtr,
961 std::unique_ptr< te::rst::Raster >& outRasterPtr,
962 std::vector< double > const* slicesLimitsPtr,
963 std::vector< double > const* slicesOutputValuesPtr );
964
965 /*!
966 \brief Replace a contiguos segment pixel values.
967 \param inputRaster Input raster.
968 \param inputRasterBandIdx Input raster band to use.
969 \param targetRow Target row (a point inside the target segment).
970 \param targetCol Target col (a point inside the target segment).
971 \param outputValue Output segment final value.
972 \return true if OK, false on errors.
973 \ingroup rp_func
974 */
976 te::rst::Raster& inputRaster,
977 const unsigned int& inputRasterBandIdx,
978 const unsigned targetRow,
979 const unsigned targetCol,
980 const double& outputValue );
981
982 /*!
983 \brief Replace a contiguos segment pixel values.
984 \param inputRaster Input raster.
985 \param inputRasterBandIdx Input raster band to use.
986 \param outputRaster Input raster.
987 \param outputRasterBandIdx Input raster band to use.
988 \param targetRow Target row (a point inside the target segment).
989 \param targetCol Target col (a point inside the target segment).
990 \param outputValue Output segment final value.
991 \return true if OK, false on errors.
992 \ingroup rp_func
993 */
995 const te::rst::Raster& inputRaster,
996 const unsigned int& inputRasterBandIdx,
997 te::rst::Raster& outputRaster,
998 const unsigned int& outputRasterBandIdx,
999 const unsigned targetInputRow,
1000 const unsigned targetInputCol,
1001 const double& outputValue );
1002
1003 /*!
1004 \brief Compute and return the histogram soccurring values (real and imaginary) inside defined regions of interest.
1005
1006 \param raster Input raster.
1007 \param bandIndex Band index.
1008 \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.
1009 \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.
1010 \param maxThreads Maximum number of used threads to use (0-Automatic, 1-No threads used).
1011 \param roisItType ROIs polygons iteration type.
1012 \param rHistogram The generated histogram (real).
1013 \param iHistogram The generated histogram (imaginary).
1014 \return true if ok, false on errors
1015 \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).
1016 \ingroup rp_func
1017 */
1019 const te::rst::Raster& raster,
1020 const unsigned int bandIndex,
1021 const std::vector< te::gm::Polygon const* >& rois,
1022 const unsigned int histoBins,
1023 const unsigned int maxThreads,
1025 std::map<double, unsigned>& rHistogram,
1026 std::map<double, unsigned>& iHistogram );
1027
1028 /*!
1029 \brief Compute statiscts from the given histogram.
1030
1031 \param histogram Input histogram.
1032 \param min Histogram minimun value.
1033 \param max Histogram maximum value.
1034 \param mean Histogram mean value.
1035 \param stdDev Histogram standard deviation value.
1036 \param mode Histogram mode value.
1037 \param entropy Histogram mode value.
1038 \param sum Sum of all pixels values.
1039 \param sum2 Quadratic sum of all pixels values.
1040 \param sum3 The cubic sum of pixels values.
1041 \param sum4 The quartic sum of pixels values.
1042 \param variance Histogram variance value.
1043 \param median Histogram median value.
1044 \ingroup rp_func
1045 */
1047 const std::map<double, unsigned int>& histogram,
1048 double& min,
1049 double& max,
1050 double& mean,
1051 double& stdDev,
1052 double& mode,
1053 double& entropy,
1054 double& sum,
1055 double& sum2,
1056 double& sum3,
1057 double& sum4,
1058 double& variance,
1059 double& median
1060 );
1061
1062 /*!
1063 \brief Compute and return the joint histogram of occurring values (real and imaginary) inside defined regions of interest.
1064 \param raster Input raster.
1065 \param bandIndex1 Input raster Band 1 index.
1066 \param bandIndex2 Input raster Band 2 index.
1067 \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.
1068 \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.
1069 \param maxThreads Maximum number of used threads to use (0-Automatic, 1-No threads used).
1070 \param roisItType ROIs polygons iteration type.
1071 \param realJointHistogram The generated joint histogram (real).
1072 \param imagJointHistogram The generated joint histogram (imaginary).
1073 \param rasterRealHistogram1ptr A pointer to a pre-calculated input raster band 1 histogram (real) or a null pointer.
1074 \param rasterImagHistogram1Ptr A pointer to a pre-calculated input raster band 1 histogram (imaginary) or a null pointer.
1075 \param rasterRealHistogram2Ptr A pointer to a pre-calculated input raster band 2 histogram (real) or a null pointer.
1076 \param rasterImagHistogram2Ptr A pointer to a pre-calculated input raster band 2 histogram (imaginary) or a null pointer.
1077 \return true if ok, false on errors
1078 \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).
1079 \ingroup rp_func
1080 */
1082 const te::rst::Raster& raster,
1083 const unsigned int bandIndex1,
1084 const unsigned int bandIndex2,
1085 const std::vector< te::gm::Polygon const* >& rois,
1086 const unsigned int histoBins,
1087 const unsigned int maxThreads,
1089 std::map< std::pair< double, double >, unsigned int>& realJointHistogram,
1090 std::map< std::pair< double, double >, unsigned int>& imagJointHistogram,
1091 std::map<double, unsigned int> const * const rasterRealHistogram1ptr,
1092 std::map<double, unsigned int> const * const rasterImagHistogram1Ptr,
1093 std::map<double, unsigned int> const * const rasterRealHistogram2Ptr,
1094 std::map<double, unsigned int> const * const rasterImagHistogram2Ptr );
1095
1096 /*!
1097 \brief Compute statiscts from the given histogram.
1098
1099 \param jointHistogram Input joint histogram where std::pair< double, double >.first are histogram1 values and std::pair< double, double >.second are histogram2 values
1100 \param histogram1 Histogram 1.
1101 \param histogram2 Histogram 2.
1102 \param covariance Calculated covariance value.
1103 \param corrlationCoef Pearson's Correlation coeficient.
1104 \return true if ok, false on errors.
1105 */
1107 const std::map< std::pair< double, double >, unsigned int>& jointHistogram,
1108 const std::map<double, unsigned int>& histogram1,
1109 const std::map<double, unsigned int>& histogram2,
1110 double& covariance,
1111 double& corrlationCoef );
1112
1113 /*!
1114 \param Fill the target band with the target value.
1115 \param bandIndex Band index.
1116 \param value Target value.
1117 \return true if OK, false on errors.
1118 \ingroup rp_func
1119 */
1121 te::rst::Raster& raster,
1122 const unsigned int bandIndex,
1123 const std::complex< double >& value );
1124
1125 /*!
1126 \brief Compute the external raster valid data area polygon.
1127 \param inputRaster Input raster.
1128 \param inputRasterBandsIdx Input raster bands to use.
1129 \param bandNoDataValues Optional vector of no-data values for each target band or an empty vector to use the original raster no-data values..
1130 \param outPolygonPtr The computed external valid data area polygon.
1131 \return true if OK, false on errors.
1132 \note The pixel centers will be used as coords.
1133 \note The returned polygon is a convex hull.
1134 \note If no valid raster data is present, this function returns false.
1135 \ingroup rp_func
1136 */
1138 const te::rst::Raster& inputRaster,
1139 const std::vector< unsigned int >& inputRasterBandsIdx,
1140 const std::vector< double >& bandNoDataValues,
1141 std::unique_ptr< te::gm::Polygon >& outPolygonPtr );
1142
1143 } // end namespace rp
1144} // end namespace te
1145
1146#endif // __TERRALIB_RP_INTERNAL_FUNCTIONS_H
1147
Raster objects feeders.
#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:230
Generic template matrix.
Raster tuple.
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
void add(Geometry *g)
It adds the geometry into the collection.
virtual Geometry * convexHull() const _NOEXCEPT_OP(false)
This method calculates the Convex Hull of a geometry.
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:54
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:54
A point with x and y coordinate values.
Definition: Point.h:51
Surface is an abstract class that represents a 2-dimensional geometric objects.
Definition: Surface.h:55
A generic template matrix.
Definition: Matrix.h:55
unsigned int getLinesNumber() const
The number of current matrix lines.
Definition: Matrix.h:782
unsigned int getColumnsNumber() const
The number of current matrix columns.
Definition: Matrix.h:789
RasterHandler.
Definition: RasterHandler.h:48
A raster band description.
Definition: BandProperty.h:62
A rectified grid is the spatial support for raster data.
Definition: Grid.h:69
static Raster * make()
It creates and returns an empty raster with default raster driver.
An abstract class for raster data strucutures.
Definition: Raster.h:72
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.
double GetTPConvexHullArea(const ContainerT &tiePoints, const bool useTPSecondCoordPair)
Returns the tie points converx hull area.
Definition: Functions.h:884
TERPEXPORT std::string GetSensorFilename()
Returns a json filename with spectral sensors parameters.
TERPEXPORT bool ComposeBands(const std::vector< te::rst::Raster const * > &inputRasters, 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, const bool allowNoDataPixels, const bool enableProgress, std::unique_ptr< te::rst::Raster > &outputRasterPtr)
Compose a set of bands into one multi-band raster.
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.
TERPEXPORT bool GetExternalValidDataPolygon(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBandsIdx, const std::vector< double > &bandNoDataValues, std::unique_ptr< te::gm::Polygon > &outPolygonPtr)
Compute the external raster valid data area polygon.
void TERPEXPORT ConvertDoublesVector(double *inputVector, unsigned int inputVectorSize, const int outputVectorDataType, void *outputVector)
Convert a doubles vector.
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.
TERPEXPORT double GetSpectralBandMin(std::string bandName)
Returns the minimum reflectance value of a given sensor/band.
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.
TERPEXPORT std::map< std::string, SpectralSensorParams > getSensorParams()
Returns a map with spectral sensors parameters defined in SpectralSensor.json file.
TERPEXPORT bool GetStdDevValue(const te::rst::Raster &inputRaster, const unsigned int inputBandIndex, const unsigned int maxThreads, const bool forceNoDataValue, const double noDataValue, double const *const meanValuePtr, double &stdDevValue)
Get the standard deviation of band pixel values.
TERPEXPORT void SaveSensorParams(std::map< std::string, SpectralSensorParams > &)
Saves in SpectralSensor.json file the spectral sensors parameters.
TERPEXPORT boost::numeric::ublas::matrix< double > CreateWaveletAtrousFilter(const WaveletAtrousFilterType &filterType)
Create a Wavele Atrous Filter.
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.
TERPEXPORT double GetSpectralBandMax(std::string bandName)
Returns the maximum reflectance value of a given sensor/band.
TERPEXPORT double GetDigitalNumberBandMin(std::string bandName)
Returns the minimum digital number of a given sensor/band.
bool TERPEXPORT Copy2DiskRaster(const te::rst::Raster &inputRaster, const std::string &fileName)
Create a new raster into a GDAL datasource.
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.
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.
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.
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.
TERPEXPORT std::vector< std::string > GetBandNames()
Returns a vector os with band's names.
TERPEXPORT bool NormalizeRaster(te::rst::Raster &inputRaster, double nmin=0.0, double nmax=255.0)
Normalizes one raster in a given interval.
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.
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
TERPEXPORT double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band.
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...
TERPEXPORT void GetAllSpectralBandInfos(std::map< std::string, struct SpectralSensorParams > &specBandInfos)
Get all spectral band infos.
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...
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.
TERPEXPORT bool GetMeanValue(const te::rst::Raster &inputRaster, const unsigned int inputBandIndex, const unsigned int maxThreads, const bool forceNoDataValue, const double noDataValue, double &meanValue)
Get the mean of band pixel values.
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.
TERPEXPORT bool FillBand(te::rst::Raster &raster, const unsigned int bandIndex, const std::complex< double > &value)
TERPEXPORT bool GetDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &detailedExtent)
Create a datailed extent from the given grid.
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
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.
TERPEXPORT void CreateFixedStepPalette(const unsigned int paletteSize, const bool randomize, std::vector< te::rst::BandProperty::ColorEntry > &palette)
Create a fixed step sequential color palette.
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.
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.
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.
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.
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.
WaveletAtrousFilterType
Wavelet Atrous Filter types.
Definition: Functions.h:75
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...
TERPEXPORT bool GetSpectralBandInfo(const std::string &bandName, SpectralSensorParams &specBandInfo)
Get the maximun and minimum reflectance values of a given sensor/band.
TERPEXPORT bool GetIndexedDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &indexedDetailedExtent)
Create a indexed (lines,columns) datailed extent from the given grid.
void TERPEXPORT Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements.
TERPEXPORT std::pair< double, double > GetDigitalNumberBandInfo(std::string bandName)
Returns the maximun and minimum digital numbers of a given sensor/band.
@ B3SplineWAFilter
Spline filter type.
Definition: Functions.h:77
@ TriangleWAFilter
Triangle filter type.
Definition: Functions.h:78
@ InvalidWAFilter
Invalid filter type.
Definition: Functions.h:76
@ DOUBLE_TYPE
Definition: Enums.h:198
@ UCHAR_TYPE
Definition: Enums.h:189
@ MultiPointType
Definition: Enums.h:84
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, double &corrlationCoef)
Compute statiscts from the given histogram.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
@ GrayIdxCInt
Index into a lookup table.
Definition: Enums.h:57
@ Grid
Definition: Enums.h:106
TerraLib.
SpectralSensorParams(const int &band, const double &lower, const double &upper, const double &min, const double &max)
Definition: Functions.h:85
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
Proxy configuration file for TerraView (see terraview_config.h).