25 #ifndef __TERRALIB_RP_INTERNAL_FUNCTIONS_H
26 #define __TERRALIB_RP_INTERNAL_FUNCTIONS_H
33 #include "../dataaccess/datasource/DataSource.h"
34 #include "../raster/Raster.h"
35 #include "../raster/RasterFactory.h"
36 #include "../raster/Grid.h"
37 #include "../raster/BandProperty.h"
38 #include "../raster/RasterFactory.h"
39 #include "../raster/Interpolator.h"
40 #include "../raster/Utils.h"
41 #include "../srs/Converter.h"
42 #include "../geometry/LinearRing.h"
43 #include "../geometry/GTParameters.h"
44 #include "../geometry/MultiPoint.h"
45 #include "../geometry/Surface.h"
55 #include <boost/numeric/ublas/matrix.hpp>
56 #include <boost/shared_ptr.hpp>
93 const std::vector< te::rst::BandProperty* >& bandsProperties,
94 const std::string& outDataSetName,
95 const std::string& dataSourceType,
96 RasterHandler& outRasterHandler );
110 const std::vector< te::rst::BandProperty* >& bandsProperties,
111 const std::string& outDataSetName,
113 RasterHandler& outRasterHandler );
125 std::vector< te::rst::BandProperty* > bandsProperties,
126 RasterHandler& outRasterHandler );
139 std::vector< te::rst::BandProperty* > bandsProperties,
140 const std::string& fileName,
141 RasterHandler& outRasterHandler );
154 std::vector< te::rst::BandProperty* > bandsProperties,
155 const std::string& fileName,
156 std::auto_ptr< te::rst::Raster >& outRasterPtr );
170 const std::string& fileName );
195 unsigned int inputVectorSize,
double* outputVector );
207 unsigned int inputVectorSize,
const int outputVectorDataType,
208 void* outputVector );
218 template<
typename MatrixElementT >
220 const bool normalize,
const std::string& fileName )
222 std::map<std::string, std::string> rInfo;
223 rInfo[
"URI"] = fileName;
225 std::vector<te::rst::BandProperty*> bandsProperties;
231 bandsProperties[0]->m_noDataValue = -1.0 * std::numeric_limits<double>::max();
236 std::auto_ptr< te::rst::Raster > outputRasterPtr(
240 unsigned int line = 0;
241 unsigned int col = 0;
244 MatrixElementT matrixValue = 0;
246 MatrixElementT gain = 1.0;
247 MatrixElementT offset = 0.0;
250 MatrixElementT matrixValueMin = std::numeric_limits< MatrixElementT >::max();
251 MatrixElementT matrixValueMax = -1.0 * matrixValueMin;
252 for( line = 0 ; line < nLines ; ++line )
254 for( col = 0 ; col < nCols ; ++col )
256 matrixValue = matrix[ line ][ col ];
257 if( matrixValue < matrixValueMin )
258 matrixValueMin = matrixValue;
259 if( matrixValue > matrixValueMax )
260 matrixValueMax = matrixValue;
264 if( matrixValueMax == matrixValueMin )
271 gain = 255.0 / ( matrixValueMax - matrixValueMin );
272 offset = -1.0 * ( matrixValueMin );
276 const MatrixElementT min0 = 0;
277 const MatrixElementT max255 = 255;
279 for( line = 0 ; line < nLines ; ++line )
281 for( col = 0 ; col < nCols ; ++col )
283 matrixValue = matrix[ line ][ col ];
287 matrixValue += offset;
289 matrixValue = std::max( min0, matrixValue );
290 matrixValue = std::min( max255, matrixValue );
293 outputRasterPtr->setValue( col, line, (
double)matrixValue, 0 );
363 const unsigned int redBandIdx,
const unsigned int greenBandIdx,
364 const unsigned int blueBandIdx,
const double rgbRangeMin,
381 const unsigned int intensityBandIdx,
const unsigned int hueBandIdx,
382 const unsigned int saturationBandIdx,
const double rgbRangeMin,
396 const unsigned int maxThreads,
411 const unsigned int maxThreads,
412 double const *
const meanValuePtr,
413 double& stdDevValue );
430 const unsigned int maxThreads,
431 double const *
const mean1ValuePtr,
432 double const *
const mean2ValuePtr,
433 double& covarianceValue );
449 const std::vector< unsigned int >& inputRasterBands,
450 boost::numeric::ublas::matrix< double >& pcaMatrix,
452 const std::vector< unsigned int >& pcaRasterBands,
453 const unsigned int maxThreads );
468 const boost::numeric::ublas::matrix< double >& pcaMatrix,
470 const std::vector< unsigned int >& outputRasterBands,
471 const unsigned int maxThreads );
487 const std::vector< unsigned int >& inputRasterBands,
488 const boost::numeric::ublas::matrix< double >& remapMatrix,
490 const std::vector< unsigned int >& outputRasterBands,
491 const unsigned int maxThreads );
505 const std::vector< unsigned int >& inputRasterBands,
506 const std::vector< std::map<std::string, std::string> > & outputRastersInfos,
507 const std::string& outputDataSourceType,
508 std::vector< boost::shared_ptr< te::rst::Raster > > & outputRastersPtrs );
524 const std::vector< unsigned int >& inputRasterBands,
526 const std::map<std::string, std::string>& outputRasterInfo,
527 const std::string& outputDataSourceType,
528 std::auto_ptr< te::rst::Raster >& outputRasterPtr );
556 TERPEXPORT boost::numeric::ublas::matrix< double >
573 const std::vector< unsigned int >& inputRasterBands,
575 const unsigned int levelsNumber,
576 const boost::numeric::ublas::matrix< double >& filter );
592 const unsigned int levelsNumber,
594 const std::vector< unsigned int >& outputRasterBands );
614 const std::vector< unsigned int >& inputRasterBands,
616 const unsigned int firstRow,
617 const unsigned int firstColumn,
618 const unsigned int height,
619 const unsigned int width,
620 const unsigned int newheight,
621 const unsigned int newwidth,
622 const std::map<std::string, std::string>& rinfo,
623 const std::string& dataSourceType,
624 std::auto_ptr< te::rst::Raster >& resampledRasterPtr );
632 template<
typename ContainerT >
634 const bool useTPSecondCoordPair )
636 if( tiePoints.size() < 3 )
644 typename ContainerT::const_iterator it =
646 const typename ContainerT::const_iterator itE =
651 if( useTPSecondCoordPair )
659 std::auto_ptr< te::gm::Geometry > convexHullPolPtr( points.
convexHull() );
661 if( dynamic_cast< te::gm::Surface* >( convexHullPolPtr.get() ) )
675 #endif // __TERRALIB_RP_INTERNAL_FUNCTIONS_H
TERPEXPORT bool GetMeanValue(const te::rst::Band &band, const unsigned int maxThreads, double &meanValue)
Get the mean of band pixel values.
TERPEXPORT double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band.
Index into a lookup table.
A raster band description.
virtual Geometry * convexHull() const
This method calculates the Convex Hull of a geometry.
double GetTPConvexHullArea(const ContainerT &tiePoints, const bool useTPSecondCoordPair)
Returns the tie points converx hull area.
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.
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)...
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, std::auto_ptr< te::rst::Raster > &outputRasterPtr)
Compose a set of bands into one multi-band raster.
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 std::vector< std::string > GetBandNames()
Returns a vector os with band's names.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
TERPEXPORT std::pair< double, double > GetDigitalNumberBandInfo(std::string bandName)
Returns the maximun and minimum digital numbers of a given sensor/band.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
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 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.
InterpolationMethod
Allowed interpolation methods.
TERPEXPORT double GetSpectralBandMax(std::string bandName)
Returns the maximum reflectance value of a given sensor/band.
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.
TERPEXPORT std::pair< double, double > GetSpectralBandInfo(std::string bandName)
Returns the maximun and minimum reflectance values of a given sensor/band.
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.
#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...
bool CreateRasterFileFromMatrix(const te::rp::Matrix< MatrixElementT > &matrix, const bool normalize, const std::string &fileName)
Create a tiff file from a matrix.
bool TERPEXPORT Copy2DiskRaster(const te::rst::Raster &inputRaster, const std::string &fileName)
Create a new raster into a GDAL datasource.
A LinearRing is a LineString that is both closed and simple.
MultiPoint is a GeometryCollection whose elements are restricted to points.
A point with x and y coordinate values.
TERPEXPORT bool NormalizeRaster(te::rst::Raster &inputRaster, double nmin=0.0, double nmax=255.0)
Normalizes one raster in a given interval.
An abstract class for raster data strucutures.
unsigned int getColumnsNumber() const
The number of current matrix columns.
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.
WaveletAtrousFilterType
Wavelet Atrous Filter types.
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.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
void TERPEXPORT Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements.
A raster band description.
TERPEXPORT bool GetDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &detailedExtent)
Create a datailed extent from the given grid.
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 boost::numeric::ublas::matrix< double > CreateWaveletAtrousFilter(const WaveletAtrousFilterType &filterType)
Create a Wavele Atrous Filter.
TERPEXPORT bool GetCovarianceValue(const te::rst::Band &band1, const te::rst::Band &band2, const unsigned int maxThreads, double const *const mean1ValuePtr, double const *const mean2ValuePtr, double &covarianceValue)
Get the covariance of band pixel values.
Configuration flags for the Raster Processing module of TerraLib.
TERPEXPORT double GetSpectralBandMin(std::string bandName)
Returns the minimum reflectance value of a given sensor/band.
Feeder from a input rasters.
void add(Geometry *g)
It adds the geometry into the collection.
A generic template matrix.
TERPEXPORT bool GetIndexedDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &indexedDetailedExtent)
Create a indexed (lines,columns) datailed extent from the given grid.
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 RasterResample(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const te::rst::Interpolator::Method interpMethod, 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::auto_ptr< te::rst::Raster > &resampledRasterPtr)
Resample a subset of the raster, given a box.
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.
static Raster * make()
It creates and returns an empty raster with default raster driver.
A rectified grid is the spatial support for raster data.
unsigned int getLinesNumber() const
The number of current matrix lines.
TERPEXPORT bool GetStdDevValue(const te::rst::Band &band, const unsigned int maxThreads, double const *const meanValuePtr, double &stdDevValue)
Get the standard deviation of band pixel values.
void TERPEXPORT ConvertDoublesVector(double *inputVector, unsigned int inputVectorSize, const int outputVectorDataType, void *outputVector)
Convert a doubles vector.
Surface is an abstract class that represents a 2-dimensional geometric objects.