25 #ifndef __TERRALIB_RP_INTERNAL_FUNCTIONS_H
26 #define __TERRALIB_RP_INTERNAL_FUNCTIONS_H
32 #include "../dataaccess/datasource/DataSource.h"
33 #include "../raster/Raster.h"
34 #include "../raster/RasterFactory.h"
35 #include "../raster/Grid.h"
36 #include "../raster/BandProperty.h"
37 #include "../raster/RasterFactory.h"
38 #include "../raster/Utils.h"
48 #include <boost/numeric/ublas/matrix.hpp>
74 const std::vector< te::rst::BandProperty* >& bandsProperties,
75 const std::string& outDataSetName,
76 const std::string& dataSourceType,
77 RasterHandler& outRasterHandler );
91 const std::vector< te::rst::BandProperty* >& bandsProperties,
92 const std::string& outDataSetName,
94 RasterHandler& outRasterHandler );
106 std::vector< te::rst::BandProperty* > bandsProperties,
107 RasterHandler& outRasterHandler );
120 std::vector< te::rst::BandProperty* > bandsProperties,
121 const std::string& fileName,
122 RasterHandler& outRasterHandler );
136 const std::string& fileName );
161 unsigned int inputVectorSize,
double* outputVector );
173 unsigned int inputVectorSize,
const int outputVectorDataType,
174 void* outputVector );
184 template<
typename MatrixElementT >
186 const bool normalize,
const std::string& fileName )
188 std::map<std::string, std::string> rInfo;
189 rInfo[
"URI"] = fileName;
191 std::vector<te::rst::BandProperty*> bandsProperties;
197 bandsProperties[0]->m_noDataValue = -1.0 * std::numeric_limits<double>::max();
202 std::auto_ptr< te::rst::Raster > outputRasterPtr(
206 unsigned int line = 0;
207 unsigned int col = 0;
210 MatrixElementT matrixValue = 0;
212 MatrixElementT gain = 1.0;
213 MatrixElementT offset = 0.0;
216 MatrixElementT matrixValueMin = std::numeric_limits< MatrixElementT >::max();
217 MatrixElementT matrixValueMax = -1.0 * matrixValueMin;
218 for( line = 0 ; line < nLines ; ++line )
220 for( col = 0 ; col < nCols ; ++col )
222 matrixValue = matrix[ line ][ col ];
223 if( matrixValue < matrixValueMin )
224 matrixValueMin = matrixValue;
225 if( matrixValue > matrixValueMax )
226 matrixValueMax = matrixValue;
230 if( matrixValueMax == matrixValueMin )
237 gain = 255.0 / ( matrixValueMax - matrixValueMin );
238 offset = -1.0 * ( matrixValueMin );
242 const MatrixElementT min0 = 0;
243 const MatrixElementT max255 = 255;
245 for( line = 0 ; line < nLines ; ++line )
247 for( col = 0 ; col < nCols ; ++col )
249 matrixValue = matrix[ line ][ col ];
253 matrixValue += offset;
255 matrixValue = std::max( min0, matrixValue );
256 matrixValue = std::min( max255, matrixValue );
259 outputRasterPtr->setValue( col, line, (
double)matrixValue, 0 );
340 const unsigned int redBandIdx,
const unsigned int greenBandIdx,
341 const unsigned int blueBandIdx,
const double rgbRangeMin,
358 const unsigned int intensityBandIdx,
const unsigned int hueBandIdx,
359 const unsigned int saturationBandIdx,
const double rgbRangeMin,
372 const unsigned int maxThreads,
386 const unsigned int maxThreads,
387 double const *
const meanValuePtr,
388 double& stdDevValue );
405 const unsigned int maxThreads,
406 double const *
const mean1ValuePtr,
407 double const *
const mean2ValuePtr,
408 double& covarianceValue );
423 const std::vector< unsigned int >& inputRasterBands,
424 boost::numeric::ublas::matrix< double >& pcaMatrix,
426 const unsigned int maxThreads );
440 const boost::numeric::ublas::matrix< double >& pcaMatrix,
442 const unsigned int maxThreads );
457 const std::vector< unsigned int >& inputRasterBands,
458 const boost::numeric::ublas::matrix< double >& remapMatrix,
460 const unsigned int maxThreads );
465 #endif // __TERRALIB_RP_INTERNAL_FUNCTIONS_H
double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
Index into a lookup table.
A raster band description.
bool GetMeanValue(const te::rst::Band &band, const unsigned int maxThreads, double &meanValue)
Get the mean of band pixel values.
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)...
std::vector< std::string > GetBandNames()
Returns a vector os with band's names.
bool CreateNewMemRaster(const te::rst::Grid &rasterGrid, std::vector< te::rst::BandProperty * > bandsProperties, RasterHandler &outRasterHandler)
Create a new raster into a new memory datasource.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
double GetSpectralBandMax(std::string bandName)
Returns the maximum reflectance value of a given sensor/band.
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.
bool NormalizeRaster(te::rst::Raster &inraster, double nmin, double nmax)
Normalizes one raster in a given interval.
An abstract class for raster data strucutures.
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.
unsigned int getColumnsNumber() const
The number of current matrix columns.
std::pair< double, double > GetDigitalNumberBandInfo(std::string bandName)
Returns the maximun and minimum digital numbers of a given sensor/band.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
void Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements.
bool DirectPrincipalComponents(const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, boost::numeric::ublas::matrix< double > &pcaMatrix, te::rst::Raster &pcaRaster, const unsigned int maxThreads)
Generate all principal components from the given input raster.
A raster band description.
std::vector< te::gm::Point * > GetRandomPointsInRaster(const te::rst::Raster &inputRaster, unsigned int numberOfPoints)
Creates a vector of random positions (points) inside the raster.
bool 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.
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.
double GetSpectralBandMin(std::string bandName)
Returns the minimum reflectance value of a given sensor/band.
A generic template matrix.
static Raster * make()
It creates and returns an empty raster with default raster driver.
bool InversePrincipalComponents(const te::rst::Raster &pcaRaster, const boost::numeric::ublas::matrix< double > &pcaMatrix, te::rst::Raster &outputRaster, const unsigned int maxThreads)
Regenerate the original raster from its principal components.
bool 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.
std::pair< double, double > GetSpectralBandInfo(std::string bandName)
Returns the maximun and minimum reflectance values of a given sensor/band.
A rectified grid is the spatial support for raster data.
unsigned int getLinesNumber() const
The number of current matrix lines.
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 unsigned int maxThreads)
Remap pixel values using a remap function matrix.
void ConvertDoublesVector(double *inputVector, unsigned int inputVectorSize, const int outputVectorDataType, void *outputVector)
Convert a doubles vector.