26 #ifndef __TERRALIB_RP_INTERNAL_FUNCTIONS_H
27 #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"
41 #include <boost/numeric/ublas/lu.hpp>
42 #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 );
90 const std::vector< te::rst::BandProperty* >& bandsProperties,
91 const std::string& outDataSetName,
93 RasterHandler& outRasterHandler );
104 std::vector< te::rst::BandProperty* > bandsProperties,
105 RasterHandler& outRasterHandler );
117 std::vector< te::rst::BandProperty* > bandsProperties,
118 const std::string& fileName,
119 RasterHandler& outRasterHandler );
139 unsigned int inputVectorSize,
double* outputVector );
150 unsigned int inputVectorSize,
const int outputVectorDataType,
151 void* outputVector );
160 template<
typename MatrixElementT >
162 const bool normalize,
const std::string& fileName )
164 std::map<std::string, std::string> rInfo;
165 rInfo[
"URI"] = fileName;
167 std::vector<te::rst::BandProperty*> bandsProperties;
173 bandsProperties[0]->m_noDataValue = -1.0 * std::numeric_limits<double>::max();
178 std::auto_ptr< te::rst::Raster > outputRasterPtr(
182 unsigned int line = 0;
183 unsigned int col = 0;
186 MatrixElementT matrixValue = 0;
188 MatrixElementT gain = 1.0;
189 MatrixElementT offset = 0.0;
192 MatrixElementT matrixValueMin = std::numeric_limits< MatrixElementT >::max();
193 MatrixElementT matrixValueMax = -1.0 * matrixValueMin;
194 for( line = 0 ; line < nLines ; ++line )
196 for( col = 0 ; col < nCols ; ++col )
198 matrixValue = matrix[ line ][ col ];
199 if( matrixValue < matrixValueMin )
200 matrixValueMin = matrixValue;
201 if( matrixValue > matrixValueMax )
202 matrixValueMax = matrixValue;
206 if( matrixValueMax == matrixValueMin )
213 gain = 255.0 / ( matrixValueMax - matrixValueMin );
214 offset = -1.0 * ( matrixValueMin );
218 const MatrixElementT min0 = 0;
219 const MatrixElementT max255 = 255;
221 for( line = 0 ; line < nLines ; ++line )
223 for( col = 0 ; col < nCols ; ++col )
225 matrixValue = matrix[ line ][ col ];
229 matrixValue += offset;
231 matrixValue = std::max( min0, matrixValue );
232 matrixValue = std::min( max255, matrixValue );
235 outputRasterPtr->setValue( col, line, (
double)matrixValue, 0 );
294 const unsigned int redBandIdx,
const unsigned int greenBandIdx,
295 const unsigned int blueBandIdx,
const double rgbRangeMin,
311 const unsigned int intensityBandIdx,
const unsigned int hueBandIdx,
312 const unsigned int saturationBandIdx,
const double rgbRangeMin,
318 #endif // __TERRALIB_RP_INTERNAL_FUNCTIONS_H
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 NormalizeRaster(te::rst::Raster &inraster, double nmin, double nmax)
Normalizes one raster in a given interval.
double GetSpectralBandMax(std::string bandName)
Returns the maximum reflectance value of a given sensor/band.
static Raster * make()
It creates and returns an empty raster with default raster driver.
unsigned int getLinesNumber() const
The number of current matrix lines.
double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band.
bool ConvertRBG2IHS(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.
void Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements.
#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...
double GetSpectralBandMin(std::string bandName)
Returns the minimum reflectance value of a given sensor/band.
A rectified grid is the spatial support for raster data.
std::pair< double, double > GetSpectralBandInfo(std::string bandName)
Returns the maximun and minimum reflectance values of a given sensor/band.
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::vector< std::string > GetBandNames()
Returns a vector os with band's names.
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 CreateNewMemRaster(const te::rst::Grid &rasterGrid, std::vector< te::rst::BandProperty * > bandsProperties, RasterHandler &outRasterHandler)
Create a new raster into a new memory datasource.
std::pair< double, double > GetDigitalNumberBandInfo(std::string bandName)
Returns the maximun and minimum digital numbers of a given sensor/band.
Configuration flags for the Raster Processing module of TerraLib.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
bool CreateRasterFileFromMatrix(const te::rp::Matrix< MatrixElementT > &matrix, const bool normalize, const std::string &fileName)
Create a tiff file from a matrix.
A raster band description.
A generic template matrix.
void 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)...
unsigned int getColumnsNumber() const
The number of current matrix columns.
An abstract class for raster data strucutures.
void ConvertDoublesVector(double *inputVector, unsigned int inputVectorSize, const int outputVectorDataType, void *outputVector)
Convert a doubles vector.
Index into a lookup table.
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.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.