30 #include "../dataaccess/dataset/DataSetType.h" 
   31 #include "../dataaccess/datasource/DataSourceFactory.h" 
   32 #include "../dataaccess/utils/Utils.h" 
   33 #include "../datatype/Enums.h" 
   34 #include "../raster/BandProperty.h" 
   35 #include "../raster/Grid.h" 
   36 #include "../raster/RasterFactory.h" 
   37 #include "../raster/RasterProperty.h" 
   38 #include "../raster/RasterIterator.h" 
   39 #include "../raster/Utils.h" 
   40 #include "../geometry/Point.h" 
   41 #include "../common/MatrixUtils.h" 
   47 #include <boost/filesystem.hpp> 
   48 #include <boost/numeric/ublas/io.hpp> 
   49 #include <boost/numeric/ublas/matrix.hpp> 
   50 #include <boost/shared_ptr.hpp> 
   51 #include <boost/shared_array.hpp> 
   52 #include <boost/random.hpp> 
   53 #include <boost/random/uniform_int_distribution.hpp> 
   54 #include <boost/lexical_cast.hpp> 
   55 #include <boost/thread.hpp> 
   56 #include <boost/numeric/ublas/lu.hpp> 
   57 #include <boost/numeric/ublas/matrix.hpp> 
   68   #define M_PI       3.14159265358979323846 
  121       const std::vector< te::rst::BandProperty* >& bandsProperties,
 
  122       const std::string& outDataSetName,
 
  123       const std::string& dataSourceType,
 
  128       std::auto_ptr< te::da::DataSource > dataSourcePtr(
 
  130       if( dataSourcePtr.get() == 0 ) 
return false;      
 
  135         outDataSetName, *dataSourcePtr, internalRasterHandler ) )
 
  137         std::auto_ptr< te::da::DataSource > dummyDataSourcePtr;
 
  138         std::auto_ptr< te::da::DataSourceTransactor > transactorPtr;
 
  139         std::auto_ptr< te::da::DataSet > dataSetPtr;
 
  140         std::auto_ptr< te::rst::Raster > rasterPtr;
 
  142         internalRasterHandler.
release( dummyDataSourcePtr, transactorPtr,
 
  143           dataSetPtr, rasterPtr );
 
  145         outRasterHandler.
reset( dataSourcePtr.release(), transactorPtr.release(), 
 
  146           dataSetPtr.release(), rasterPtr.release() );
 
  157       const std::vector< te::rst::BandProperty* >& bandsProperties,
 
  158       const std::string& outDataSetName,
 
  164       std::auto_ptr< te::rst::RasterProperty > rasterPropertyPtr(
 
  166         bandsProperties, std::map< std::string, std::string >(),
 
  171       std::auto_ptr< te::da::DataSourceTransactor > transactorPtr(
 
  174       if( transactorPtr.get() == 0 )
 
  181       if( transactorPtr->dataSetExists( outDataSetName ) )
 
  183         transactorPtr->dropDataSet( outDataSetName );
 
  186       std::auto_ptr< te::da::DataSetType > dataSetTypePtr(
 
  188       dataSetTypePtr->add( rasterPropertyPtr.release() );
 
  192         transactorPtr->createDataSet( dataSetTypePtr.get(),
 
  193           std::map< std::string, std::string >() );
 
  200        if( ! transactorPtr->dataSetExists( outDataSetName ) ) 
return false;
 
  202       std::auto_ptr< te::da::DataSet > dataSetPtr( transactorPtr->getDataSet(
 
  205       if( dataSetPtr.get() == 0 )
 
  212       std::auto_ptr< te::rst::Raster > rasterPtr( dataSetPtr->getRaster( 0 ) );
 
  214       if( rasterPtr.get() )
 
  216         outRasterHandler.
reset( transactorPtr.release(), dataSetPtr.release(), rasterPtr.release() );
 
  226       std::vector< te::rst::BandProperty* > bandsProperties,
 
  229       std::string dataSetName = std::string( 
"createNewMemRaster" ) +
 
  230         boost::lexical_cast< std::string >( &outRasterHandler );
 
  233         "MEM", outRasterHandler );
 
  237       std::vector< te::rst::BandProperty* > bandsProperties,
 
  238       const std::string& fileName,
 
  242       boost::filesystem::path pathInfo( fileName );
 
  246       std::auto_ptr< te::da::DataSource > dataSourcePtr(
 
  248       if( dataSourcePtr.get() == 0 ) 
return false;
 
  250       std::map<std::string, std::string> outputRasterInfo;
 
  251       outputRasterInfo[
"SOURCE"] = pathInfo.parent_path().string().empty() ?
 
  252         "." : pathInfo.parent_path().string();
 
  254       dataSourcePtr->setConnectionInfo(outputRasterInfo);
 
  255       dataSourcePtr->open();
 
  256       if( ! dataSourcePtr->isOpened() ) 
return false;
 
  261         pathInfo.filename().string(), *dataSourcePtr, internalRasterHandler ) )
 
  263         std::auto_ptr< te::da::DataSource > dummyDataSourcePtr;
 
  264         std::auto_ptr< te::da::DataSourceTransactor > transactorPtr;
 
  265         std::auto_ptr< te::da::DataSet > dataSetPtr;
 
  266         std::auto_ptr< te::rst::Raster > rasterPtr;
 
  268         internalRasterHandler.
release( dummyDataSourcePtr, transactorPtr,
 
  269           dataSetPtr, rasterPtr );
 
  271         outRasterHandler.
reset( dataSourcePtr.release(), transactorPtr.release(), 
 
  272           dataSetPtr.release(), rasterPtr.release() );
 
  283       const std::string& fileName )
 
  293       unsigned int bandIdx =0;
 
  294       unsigned int col = 0;
 
  295       unsigned int row = 0;
 
  297       std::vector< te::rst::BandProperty* > bandsProperties;
 
  298       for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
 
  307         fileName, outRasterHandler ) )
 
  314       for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
 
  319         for( row = 0 ; row < nRows ; ++row )
 
  321           for( col = 0 ; col < nCols ; ++col )
 
  324             outBand.
setValue( col, row, value );
 
  333       unsigned int inputVectorSize, 
double* outputVector )
 
  335       switch( inputVectorDataType )
 
  339           char* vPtr = (
char*)inputVector;
 
  340           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  341             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  347           unsigned char* vPtr = (
unsigned char*)inputVector;
 
  348           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  349             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  354           short int* vPtr = (
short int*)inputVector;
 
  355           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  356             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  361           std::complex< short int >* vPtr = (std::complex< short int >*)
 
  363           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  364             outputVector[ idx ] = (
double)vPtr[ idx ].real();
 
  369           unsigned short int* vPtr = (
unsigned short int*)inputVector;
 
  370           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  371             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  376           int* vPtr = (
int*)inputVector;
 
  377           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  378             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  383           std::complex< int >* vPtr = (std::complex< int >*)
 
  385           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  386             outputVector[ idx ] = (
double)vPtr[ idx ].real();
 
  391           unsigned int* vPtr = (
unsigned int*)inputVector;
 
  392           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  393             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  398           long int* vPtr = (
long int*)inputVector;
 
  399           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  400             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  405           unsigned long int* vPtr = (
unsigned long int*)inputVector;
 
  406           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  407             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  412           float* vPtr = (
float*)inputVector;
 
  413           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  414             outputVector[ idx ] = (
double)vPtr[ idx ];
 
  419           std::complex< float >* vPtr = (std::complex< float >*)
 
  421           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  422             outputVector[ idx ] = (
double)vPtr[ idx ].real();
 
  427           memcpy( outputVector, inputVector, inputVectorSize * 
sizeof( 
double ) );
 
  432           std::complex< double >* vPtr = (std::complex< double >*)
 
  434           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  435             outputVector[ idx ] = (
double)vPtr[ idx ].real();
 
  439           throw te::rp::Exception( 
"Invalid data type" );
 
  445       unsigned int inputVectorSize, 
const int outputVectorDataType,
 
  448       switch( outputVectorDataType )
 
  452           char* vPtr = (
char*)outputVector;
 
  453           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  454             vPtr[ idx ] = (
char)inputVector[ idx ];
 
  460           unsigned char* vPtr = (
unsigned char*)outputVector;
 
  461           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  462             vPtr[ idx ] = (
unsigned char)inputVector[ idx ];
 
  467           short int* vPtr = (
short int*)outputVector;
 
  468           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  469             vPtr[ idx ] = (
short int)inputVector[ idx ];
 
  474           std::complex< short int >* vPtr = (std::complex< short int >*)
 
  476           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  477             vPtr[ idx ]= ( (
short int)inputVector[ idx ] );
 
  482           unsigned short int* vPtr = (
unsigned short int*)outputVector;
 
  483           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  484             vPtr[ idx ] = (
unsigned short int)inputVector[ idx ];
 
  489           int* vPtr = (
int*)outputVector;
 
  490           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  491             vPtr[ idx ] = (
int)inputVector[ idx ];
 
  496           std::complex< int >* vPtr = (std::complex< int >*)
 
  498           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  499             vPtr[ idx ] = ( (
int)inputVector[ idx ] );
 
  504           unsigned int* vPtr = (
unsigned int*)outputVector;
 
  505           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  506             vPtr[ idx ] = (
unsigned int)inputVector[ idx ];
 
  511           long int* vPtr = (
long int*)outputVector;
 
  512           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  513             vPtr[ idx ] = (
long int)inputVector[ idx ];
 
  518           unsigned long int* vPtr = (
unsigned long int*)outputVector;
 
  519           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  520             vPtr[ idx ] = (
unsigned long int)inputVector[ idx ];
 
  525           float* vPtr = (
float*)outputVector;
 
  526           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  527             vPtr[ idx ] = (
float)inputVector[ idx ];
 
  532           std::complex< float >* vPtr = (std::complex< float >*)
 
  534           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  535             vPtr[ idx ] = ( (
float)inputVector[ idx ] );
 
  540           memcpy( outputVector, inputVector, inputVectorSize * 
sizeof( 
double ) );
 
  545           std::complex< double >* vPtr = (std::complex< double >*)
 
  547           for( 
register unsigned int idx = 0 ; idx < inputVectorSize ; ++idx )
 
  548             vPtr[ idx ] = ( (
double)inputVector[ idx ] );
 
  552           throw te::rp::Exception( 
"Invalid data type" );
 
  559       static std::vector<std::string> bandNames;
 
  561       bandNames.push_back(
"CBERS2_CCD_1_BLUE");
 
  562       bandNames.push_back(
"CBERS2_CCD_2_GREEN");
 
  563       bandNames.push_back(
"CBERS2_CCD_3_RED");
 
  564       bandNames.push_back(
"CBERS2_CCD_4_NIR");
 
  565       bandNames.push_back(
"CBERS2_CCD_5_PAN");
 
  567       bandNames.push_back(
"LANDSAT5_TM_1_BLUE");
 
  568       bandNames.push_back(
"LANDSAT5_TM_2_GREEN");
 
  569       bandNames.push_back(
"LANDSAT5_TM_3_RED");
 
  570       bandNames.push_back(
"LANDSAT5_TM_4_NIR");
 
  571       bandNames.push_back(
"LANDSAT5_TM_5_SWIR");
 
  572       bandNames.push_back(
"LANDSAT5_TM_6_THERMAL");
 
  573       bandNames.push_back(
"LANDSAT5_TM_7_MIR");
 
  575       bandNames.push_back(
"LANDSAT7_ETM+_1_BLUE");
 
  576       bandNames.push_back(
"LANDSAT7_ETM+_2_GREEN");
 
  577       bandNames.push_back(
"LANDSAT7_ETM+_3_RED");
 
  578       bandNames.push_back(
"LANDSAT7_ETM+_4_NIR");
 
  579       bandNames.push_back(
"LANDSAT7_ETM+_5_SWIR");
 
  580       bandNames.push_back(
"LANDSAT7_ETM+_6_THERMAL");
 
  581       bandNames.push_back(
"LANDSAT7_ETM+_7_MIR");
 
  582       bandNames.push_back(
"LANDSAT7_ETM+_8_PAN");
 
  584       bandNames.push_back(
"WV2_MUL_1_COASTAL");
 
  585       bandNames.push_back(
"WV2_MUL_2_BLUE");
 
  586       bandNames.push_back(
"WV2_MUL_3_GREEN");
 
  587       bandNames.push_back(
"WV2_MUL_4_YELLOW");
 
  588       bandNames.push_back(
"WV2_MUL_5_RED");
 
  589       bandNames.push_back(
"WV2_MUL_6_REDEDGE");
 
  590       bandNames.push_back(
"WV2_MUL_7_NIR1");
 
  591       bandNames.push_back(
"WV2_MUL_8_NIR2");
 
  592       bandNames.push_back(
"WV2_PAN");
 
  599       static std::map<std::string, std::pair<double, double> > BandInfo;
 
  601       BandInfo[
"CBERS2_CCD_1_BLUE"] = std::pair<double, double> (0.45, 0.52);
 
  602       BandInfo[
"CBERS2_CCD_2_GREEN"] = std::pair<double, double> (0.52, 0.59);
 
  603       BandInfo[
"CBERS2_CCD_3_RED"] = std::pair<double, double> (0.63, 0.69);
 
  604       BandInfo[
"CBERS2_CCD_4_NIR"] = std::pair<double, double> (0.77, 0.89);
 
  605       BandInfo[
"CBERS2_CCD_5_PAN"] = std::pair<double, double> (0.51, 0.73);
 
  607       BandInfo[
"LANDSAT5_TM_1_BLUE"] = std::pair<double, double> (0.45, 0.52);
 
  608       BandInfo[
"LANDSAT5_TM_2_GREEN"] = std::pair<double, double> (0.52, 0.60);
 
  609       BandInfo[
"LANDSAT5_TM_3_RED"] = std::pair<double, double> (0.63, 0.69);
 
  610       BandInfo[
"LANDSAT5_TM_4_NIR"] = std::pair<double, double> (0.76, 0.90);
 
  611       BandInfo[
"LANDSAT5_TM_5_SWIR"] = std::pair<double, double> (1.55, 1.75);
 
  612       BandInfo[
"LANDSAT5_TM_6_THERMAL"] = std::pair<double, double> (10.40, 12.50);
 
  613       BandInfo[
"LANDSAT5_TM_7_MIR"] = std::pair<double, double> (2.08, 2.35);
 
  615       BandInfo[
"LANDSAT7_ETM+_1_BLUE"] = std::pair<double, double> (0.45, 0.515);
 
  616       BandInfo[
"LANDSAT7_ETM+_2_GREEN"] = std::pair<double, double> (0.525, 0.605);
 
  617       BandInfo[
"LANDSAT7_ETM+_3_RED"] = std::pair<double, double> (0.63, 0.69);
 
  618       BandInfo[
"LANDSAT7_ETM+_4_NIR"] = std::pair<double, double> (0.75, 0.90);
 
  619       BandInfo[
"LANDSAT7_ETM+_5_SWIR"] = std::pair<double, double> (1.55, 1.75);
 
  620       BandInfo[
"LANDSAT7_ETM+_6_THERMAL"] = std::pair<double, double> (10.40, 12.5);
 
  621       BandInfo[
"LANDSAT7_ETM+_7_MIR"] = std::pair<double, double> (2.09, 2.35);
 
  622       BandInfo[
"LANDSAT7_ETM+_8_PAN"] = std::pair<double, double> (0.52, 0.90);
 
  624       BandInfo[
"WV2_MUL_1_COASTAL"] = std::pair<double, double> (0.4, 0.45);
 
  625       BandInfo[
"WV2_MUL_2_BLUE"] = std::pair<double, double> (0.45, 0.51);
 
  626       BandInfo[
"WV2_MUL_3_GREEN"] = std::pair<double, double> (0.51, 0.58);
 
  627       BandInfo[
"WV2_MUL_4_YELLOW"] = std::pair<double, double> (0.585, 0.625);
 
  628       BandInfo[
"WV2_MUL_5_RED"] = std::pair<double, double> (0.66, 0.69);
 
  629       BandInfo[
"WV2_MUL_6_REDEDGE"] = std::pair<double, double> (0.705, 0.745);
 
  630       BandInfo[
"WV2_MUL_7_NIR1"] = std::pair<double, double> (0.77, 0.895);
 
  631       BandInfo[
"WV2_MUL_8_NIR2"] = std::pair<double, double> (0.86, 0.104);
 
  632       BandInfo[
"WV2_PAN"] = std::pair<double, double> (0.45, 0.8);
 
  636       if (BandInfo.find(bandName) == BandInfo.end())
 
  637         return std::pair<double, double> (0.0, 1.0);
 
  639       return BandInfo[bandName];
 
  654       static std::map<std::string, std::pair<double, double> > DNBandInfo;
 
  656       DNBandInfo[
"CBERS2_CCD_1_BLUE"] = std::pair<double, double> (0.0, 255.0);
 
  657       DNBandInfo[
"CBERS2_CCD_2_GREEN"] = std::pair<double, double> (0.0, 255.0);
 
  658       DNBandInfo[
"CBERS2_CCD_3_RED"] = std::pair<double, double> (0.0, 255.0);
 
  659       DNBandInfo[
"CBERS2_CCD_4_NIR"] = std::pair<double, double> (0.0, 255.0);
 
  660       DNBandInfo[
"CBERS2_CCD_5_PAN"] = std::pair<double, double> (0.0, 255.0);
 
  662       DNBandInfo[
"LANDSAT5_TM_1_BLUE"] = std::pair<double, double> (0.0, 255.0);
 
  663       DNBandInfo[
"LANDSAT5_TM_2_GREEN"] = std::pair<double, double> (0.0, 255.0);
 
  664       DNBandInfo[
"LANDSAT5_TM_3_RED"] = std::pair<double, double> (0.0, 255.0);
 
  665       DNBandInfo[
"LANDSAT5_TM_4_NIR"] = std::pair<double, double> (0.0, 255.0);
 
  666       DNBandInfo[
"LANDSAT5_TM_5_SWIR"] = std::pair<double, double> (0.0, 255.0);
 
  667       DNBandInfo[
"LANDSAT5_TM_6_THERMAL"] = std::pair<double, double> (0.0, 255.0);
 
  668       DNBandInfo[
"LANDSAT5_TM_7_MIR"] = std::pair<double, double> (0.0, 255.0);
 
  670       DNBandInfo[
"LANDSAT7_ETM+_1_BLUE"] = std::pair<double, double> (0.0, 255.0);
 
  671       DNBandInfo[
"LANDSAT7_ETM+_2_GREEN"] = std::pair<double, double> (0.0, 255.0);
 
  672       DNBandInfo[
"LANDSAT7_ETM+_3_RED"] = std::pair<double, double> (0.0, 255.0);
 
  673       DNBandInfo[
"LANDSAT7_ETM+_4_NIR"] = std::pair<double, double> (0.0, 255.0);
 
  674       DNBandInfo[
"LANDSAT7_ETM+_5_SWIR"] = std::pair<double, double> (0.0, 255.0);
 
  675       DNBandInfo[
"LANDSAT7_ETM+_6_THERMAL"] = std::pair<double, double> (0.0, 255.0);
 
  676       DNBandInfo[
"LANDSAT7_ETM+_7_MIR"] = std::pair<double, double> (0.0, 255.0);
 
  677       DNBandInfo[
"LANDSAT7_ETM+_8_PAN"] = std::pair<double, double> (0.0, 255.0);
 
  679       DNBandInfo[
"WV2_MUL_1_COASTAL"] = std::pair<double, double> (0.0, 2048.0);
 
  680       DNBandInfo[
"WV2_MUL_2_BLUE"] = std::pair<double, double> (0.0, 2048.0);
 
  681       DNBandInfo[
"WV2_MUL_3_GREEN"] = std::pair<double, double> (0.0, 2048.0);
 
  682       DNBandInfo[
"WV2_MUL_4_YELLOW"] = std::pair<double, double> (0.0, 2048.0);
 
  683       DNBandInfo[
"WV2_MUL_5_RED"] = std::pair<double, double> (0.0, 2048.0);
 
  684       DNBandInfo[
"WV2_MUL_6_REDEDGE"] = std::pair<double, double> (0.0, 2048.0);
 
  685       DNBandInfo[
"WV2_MUL_7_NIR1"] = std::pair<double, double> (0.0, 2048.0);
 
  686       DNBandInfo[
"WV2_MUL_7_NIR2"] = std::pair<double, double> (0.0, 2048.0);
 
  687       DNBandInfo[
"WV2_PAN"] = std::pair<double, double> (0.0, 2048.0);
 
  691       if (DNBandInfo.find(bandName) == DNBandInfo.end())
 
  692         return std::pair<double, double> (0.0, 255.0);
 
  694       return DNBandInfo[bandName];
 
  708       std::vector<double> omins;
 
  709       std::vector<double> omaxs;
 
  710       std::vector<unsigned int> bands;
 
  722       const double namplitude = nmax - nmin;
 
  723       std::vector<double> oamplitude;
 
  725         oamplitude.push_back(omaxs[b] - omins[b]);
 
  735           value = ((*it)[b] - omins[b]) * namplitude / oamplitude[b] + nmin;
 
  748       std::vector<te::gm::Point*> randomPoints;
 
  752       boost::random::mt19937 generator((boost::random::mt19937::result_type) time(0));
 
  753       boost::random::uniform_int_distribution<> random_rows(0, inputRaster.
getNumberOfRows() - 1);
 
  754       boost::random::uniform_int_distribution<> random_columns(0, inputRaster.
getNumberOfColumns() - 1);
 
  756       for (
unsigned int p = 0; p < numberOfPoints; p++)
 
  758         inputRaster.
getGrid()->
gridToGeo(random_columns(generator), random_rows(generator), randX, randY);
 
  766       const unsigned int redBandIdx, 
const unsigned int greenBandIdx,
 
  767       const unsigned int blueBandIdx, 
const double rgbRangeMin, 
 
  791       const double blueNoData = inputRGBRaster.
getBand( 
 
  794       unsigned int outRow = 0;
 
  795       unsigned int outCol = 0;
 
  800       double redNorm = 0, greenNorm = 0, blueNorm = 0;
 
  801       double rMinusG = 0, rMinusB = 0;
 
  804       const double twoPi = 2.0 * ((double)
M_PI);
 
  805       const double pi2 = ((double)
M_PI) / 2.0;   
 
  806       const double rgbNormFac = ( rgbRangeMax == rgbRangeMin ) ? 0.0 :
 
  807         ( 1.0 / ( rgbRangeMax - rgbRangeMin ) );
 
  808       double intensity = 0;
 
  810       double saturation = 0;
 
  812       for( outRow = 0 ; outRow < outNRows ; ++outRow )
 
  814         for( outCol = 0 ; outCol < outNCols ; ++outCol )
 
  816           redBand.
getValue( outCol, outRow, red );
 
  817           greenBand.
getValue( outCol, outRow, green );
 
  818           blueBand.
getValue( outCol, outRow, blue );
 
  820           if( ( red == redNoData ) || ( green == greenNoData ) ||
 
  821             ( blue == blueNoData ) )
 
  829             if( ( red == green ) && ( green == blue ) ) 
 
  839               intensity = ( red * rgbNormFac ); 
 
  843               redNorm = ( red - rgbRangeMin ) * rgbNormFac;
 
  844               greenNorm = ( green - rgbRangeMin ) * rgbNormFac;
 
  845               blueNorm = ( blue - rgbRangeMin ) * rgbNormFac;
 
  847               rMinusG = redNorm - greenNorm;
 
  848               rMinusB = redNorm - blueNorm;
 
  850               cosValue = std::sqrt( ( rMinusG * rMinusG ) + ( rMinusB * 
 
  851                 ( greenNorm - blueNorm ) ) );
 
  853               if( cosValue == 0.0 )
 
  859                 cosValue =  ( 0.5 * ( rMinusG + rMinusB )  ) /
 
  861                 teta = std::acos( cosValue );  
 
  864               assert( ( cosValue >= (-1.0) ) && ( cosValue <= (1.0) ) );
 
  866               if( blueNorm > greenNorm )
 
  868                 hue = ( twoPi - teta );
 
  875               rgbSum = ( redNorm + greenNorm + blueNorm );
 
  877               saturation = ( 1.0 - ( 3 * std::min( std::min( redNorm, greenNorm ), blueNorm ) /
 
  880               intensity = ( rgbSum / 3.0 );            
 
  884           outputIHSRaster.
setValue( outCol, outRow, intensity, 0 );
 
  885           outputIHSRaster.
setValue( outCol, outRow, hue, 1 );
 
  886           outputIHSRaster.
setValue( outCol, outRow, saturation, 2 );          
 
  894       const unsigned int intensityBandIdx, 
const unsigned int hueBandIdx,
 
  895       const unsigned int saturationBandIdx, 
const double rgbRangeMin, 
 
  913       const double intensityNoData = inputIHSRaster.
getBand( 
 
  915       const double hueNoData = inputIHSRaster.
getBand( 
 
  917       const double saturationNoData = inputIHSRaster.
getBand( 
 
  920       const double rgbNormFac = ( rgbRangeMax == rgbRangeMin ) ? 0.0 :
 
  921         ( rgbRangeMax - rgbRangeMin ); 
 
  922       const double pi3 = 
M_PI / 3.0; 
 
  923       const double twoPi3 = 2.0 * 
M_PI / 3.0; 
 
  924       const double fourPi3 = 4.0 * 
M_PI / 3.0; 
 
  925       unsigned int row = 0;
 
  926       unsigned int col = 0;  
 
  940       for( row = 0 ; row < nRows ; ++row )
 
  942         for( col = 0 ; col < nCols ; ++col )
 
  944           intensityBand.
getValue( col, row, lig );
 
  946           saturationBand.
getValue( col, row, sat );
 
  948           if( ( lig == intensityNoData ) || ( hue == hueNoData ) || 
 
  949             ( sat == saturationNoData ) )
 
  951             red = green = blue = 0;
 
  955             if( ( hue == 0.0 ) && ( sat == 0.0 ) )
 
  957               red = green = blue = ( lig * rgbNormFac );
 
  964                 blue = lig * ( 1.0 - sat );
 
  965                 red = lig * ( 1.0 + ( sat * std::cos( hue ) / 
 
  966                   std::cos( pi3 - hue ) ) );
 
  967                 green = ( 3.0 * lig ) - ( red + blue );
 
  969               else if( hue < fourPi3 )
 
  974                 red = lig * ( 1.0 - sat );
 
  975                 green = lig * ( 1.0 + ( sat * std::cos( hue ) / 
 
  976                   std::cos( pi3 - hue ) ) );
 
  977                 blue = ( 3.0 * lig ) - ( red + green );
 
  984                 green = lig * ( 1.0 - sat );
 
  985                 blue = lig * ( 1.0 + ( sat * std::cos( hue ) / 
 
  986                   std::cos( pi3 - hue ) ) );
 
  987                 red = ( 3.0 * lig ) - ( green + blue );
 
  990               red = ( red * rgbNormFac ) + rgbRangeMin;
 
  991               green = ( green * rgbNormFac ) + rgbRangeMin;
 
  992               blue = ( blue * rgbNormFac ) + rgbRangeMin;
 
  996           red = 
MIN( red, rgbRangeMax );
 
  997           green = 
MIN( green, rgbRangeMax );
 
  998           blue = 
MIN( blue, rgbRangeMax );
 
 1000           red = 
MAX( red, rgbRangeMin );
 
 1001           green = 
MAX( green, rgbRangeMin );
 
 1002           blue = 
MAX( blue, rgbRangeMin );           
 
 1005           greenBand.
setValue( col, row, green );
 
 1006           blueBand.
setValue( col, row, blue );
 
 1023       boost::scoped_array< unsigned char > blockBuffer( 
new unsigned char[ blockSizeBytes ] );
 
 1024       boost::scoped_array< double > doubleBuffer( 
new double[ blockElementsNumber ] );
 
 1026       unsigned int elementIdx = 0;
 
 1028       double meanElementsNumber = 0;
 
 1051               doubleBuffer.get() );
 
 1053             for( elementIdx = 0 ; elementIdx < blockElementsNumber ; ++elementIdx )
 
 1055               if( noDataValue != doubleBuffer[ elementIdx ] )
 
 1065                     doubleBuffer[ elementIdx ] 
 
 1074                 meanElementsNumber = meanElementsNumber + 1.0;
 
 1107       const unsigned int maxThreads, 
 
 1116       for( 
unsigned int row = 0 ; row < rasterBlocksStatus.
getLinesNumber() ;
 
 1122           rasterBlocksStatus( row, col ) = 
false;
 
 1128       double pixelsNumber = 0.0;
 
 1140       if( maxThreads == 1 )
 
 1148         boost::thread_group threads;
 
 1150         for( 
unsigned int threadIdx = 0 ; threadIdx < threadsNumber ;
 
 1174       boost::scoped_array< unsigned char > blockBuffer( 
new unsigned char[ blockSizeBytes ] );
 
 1175       boost::scoped_array< double > doubleBuffer( 
new double[ blockElementsNumber ] );
 
 1177       unsigned int elementIdx = 0;
 
 1179       double squaresDifsSum = 0;
 
 1180       double elementsNumber = 0;
 
 1204               doubleBuffer.get() );
 
 1206             for( elementIdx = 0 ; elementIdx < blockElementsNumber ; ++elementIdx )
 
 1208               if( noDataValue != doubleBuffer[ elementIdx ] )
 
 1210                 diff = doubleBuffer[ elementIdx ] - meanValue;
 
 1212                 squaresDifsSum += diff;
 
 1213                 elementsNumber = elementsNumber + 1.0;
 
 1232       const unsigned int maxThreads, 
double const * 
const meanValuePtr, 
 
 1233       double& stdDevValue )
 
 1238         mean = (*meanValuePtr);
 
 1254       for( 
unsigned int row = 0 ; row < rasterBlocksStatus.
getLinesNumber() ;
 
 1260           rasterBlocksStatus( row, col ) = 
false;
 
 1266       double pixelsNumber = 0.0;
 
 1279       if( maxThreads == 1 )
 
 1287         boost::thread_group threads;
 
 1289         for( 
unsigned int threadIdx = 0 ; threadIdx < threadsNumber ;
 
 1299       stdDevValue = std::sqrt( stdDevValue / pixelsNumber );
 
 1317       boost::scoped_array< unsigned char > blockBuffer1( 
new unsigned char[ blockSizeBytes1 ] );
 
 1318       boost::scoped_array< unsigned char > blockBuffer2( 
new unsigned char[ blockSizeBytes2 ] );
 
 1319       boost::scoped_array< double > doubleBuffer1( 
new double[ blockElementsNumber ] );
 
 1320       boost::scoped_array< double > doubleBuffer2( 
new double[ blockElementsNumber ] );
 
 1322       unsigned int elementIdx = 0;
 
 1323       double covariance = 0;
 
 1324       double elementsNumber = 0;
 
 1350               doubleBuffer1.get() );
 
 1352               doubleBuffer2.get() );
 
 1354             for( elementIdx = 0 ; elementIdx < blockElementsNumber ; ++elementIdx )
 
 1356               if( ( noDataValue1 != doubleBuffer1[ elementIdx ] ) &&
 
 1357                 ( noDataValue2 != doubleBuffer2[ elementIdx ] ) )
 
 1359                 diff1 = doubleBuffer1[ elementIdx ] - paramsPtr->
m_mean1Value;
 
 1360                 diff2 = doubleBuffer2[ elementIdx ] - paramsPtr->
m_mean2Value;
 
 1362                 covariance += ( diff1 * diff2 );
 
 1364                 elementsNumber = elementsNumber + 1.0;
 
 1379       double const * 
const mean1ValuePtr, 
double const * 
const mean2ValuePtr,  
 
 1380       double& covarianceValue )
 
 1397         mean1 = (*mean1ValuePtr);
 
 1410         mean2 = (*mean2ValuePtr);
 
 1431         for( 
unsigned int row = 0 ; row < rasterBlocksStatus.
getLinesNumber() ;
 
 1437             rasterBlocksStatus( row, col ) = 
false;
 
 1441         covarianceValue = 0.0;
 
 1443         double pixelsNumber = 0.0;
 
 1458         if( maxThreads == 1 )
 
 1466           boost::thread_group threads;
 
 1468           for( 
unsigned int threadIdx = 0 ; threadIdx < threadsNumber ;
 
 1478         if( pixelsNumber != 0.0 )
 
 1480           covarianceValue /= pixelsNumber;
 
 1493         unsigned int col = 0;
 
 1494         double pixelsNumber = 0.0;
 
 1496         covarianceValue = 0;
 
 1498         for( 
unsigned int row = 0 ; row < nRows ; ++row )
 
 1500           for( col = 0 ; col < nCols ; ++col )
 
 1502             band1.
getValue( col, row, value1 );
 
 1503             band2.
getValue( col, row, value2 );
 
 1505             if( ( noDataValue1 != value1 ) &&
 
 1506               ( noDataValue2 != value2 ) )
 
 1508               covarianceValue += ( ( value1 - mean1 ) * ( value2 - mean2 ) );
 
 1510               pixelsNumber = pixelsNumber + 1.0;
 
 1515         if( pixelsNumber != 0.0 )
 
 1517           covarianceValue /= pixelsNumber;
 
 1526       const std::vector< unsigned int >& inputRasterBands,
 
 1527       boost::numeric::ublas::matrix< double >& pcaMatrix,
 
 1529       const unsigned int maxThreads )
 
 1558       boost::numeric::ublas::matrix< double > covarianceMatrix;
 
 1560       covarianceMatrix.resize( inputRasterBands.size(), inputRasterBands.size() );
 
 1562       for( 
unsigned int covMatrixIdx1 = 0 ; covMatrixIdx1 < inputRasterBands.size() ;
 
 1570         for( 
unsigned int covMatrixIdx2 = 0 ; covMatrixIdx2 < inputRasterBands.size() ;
 
 1578           if( covMatrixIdx1 > covMatrixIdx2 )
 
 1580             covarianceMatrix( covMatrixIdx1, covMatrixIdx2 ) =
 
 1581               covarianceMatrix( covMatrixIdx2, covMatrixIdx1 );
 
 1586                *( inputRaster.
getBand( inputRasterBands[ covMatrixIdx2 ] ) ),
 
 1587                maxThreads, 0,  0, covarianceMatrix( covMatrixIdx1, covMatrixIdx2 ) ) )
 
 1599       boost::numeric::ublas::matrix< double > eigenValues;
 
 1600       boost::numeric::ublas::matrix< double > eigenVectors;
 
 1607       pcaMatrix = boost::numeric::ublas::trans( eigenVectors );
 
 1609       return RemapValues( inputRaster, inputRasterBands, pcaMatrix, pcaRaster, maxThreads );
 
 1614       const boost::numeric::ublas::matrix< double >& pcaMatrix,
 
 1616       const unsigned int maxThreads )    
 
 1618       boost::numeric::ublas::matrix< double > inversePcaMatrix;
 
 1624       std::vector< unsigned int > inputRasterBands;
 
 1629         inputRasterBands.push_back( bandIdx );
 
 1632       return RemapValues( pcaRaster, inputRasterBands, inversePcaMatrix, 
 
 1633         outputRaster, maxThreads );
 
 1647       const unsigned int  inputRasterBandsSize = (
unsigned int)inputRasterBands.size();
 
 1650       unsigned int maxBlocksSizesBytes = 0;
 
 1651       std::vector< double > inputBandsNoDataValues( inputRasterBandsSize, 0.0 );
 
 1652       std::vector< double > outputBandsNoDataValues( inputRasterBandsSize, 0.0 );
 
 1653       std::vector< boost::shared_array< double > > inDoubleBuffersHandlers( inputRasterBandsSize );
 
 1654       std::vector< boost::shared_array< double > > outDoubleBuffersHandlers( inputRasterBandsSize );
 
 1655       unsigned int inputRasterBandsIdx = 0;
 
 1656       boost::numeric::ublas::matrix< double > remapMatrix = *( paramsPtr->
m_remapMatrixPtr );
 
 1657       std::vector< double > outputMinValue( inputRasterBandsSize );
 
 1658       std::vector< double > outputMaxValue( inputRasterBandsSize );        
 
 1659       boost::shared_array< double* > inDoubleBuffersPtrsHandler( 
new double*[ inputRasterBandsSize ] );
 
 1660       boost::shared_array< double* > outDoubleBuffersPtrsHandler( 
new double*[ inputRasterBandsSize ] );
 
 1661       double** inDoubleBuffers = inDoubleBuffersPtrsHandler.get();
 
 1662       double** outDoubleBuffers = outDoubleBuffersPtrsHandler.get();
 
 1664       for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1665         ++inputRasterBandsIdx )
 
 1667         const unsigned int& inBandIdx = inputRasterBands[ inputRasterBandsIdx ];
 
 1668         assert( inBandIdx < paramsPtr->m_inputRasterPtr->getNumberOfBands() );
 
 1673         maxBlocksSizesBytes = std::max( maxBlocksSizesBytes, (
unsigned int)inBandPtr->getBlockSize() );
 
 1674         maxBlocksSizesBytes = std::max( maxBlocksSizesBytes, (
unsigned int)outBandPtr->
getBlockSize() );
 
 1679         inDoubleBuffersHandlers[ inputRasterBandsIdx ].reset( 
new double[ blockElementsNumber ] );
 
 1680         inDoubleBuffers[ inputRasterBandsIdx ] = inDoubleBuffersHandlers[ inputRasterBandsIdx ].get();
 
 1682         outDoubleBuffersHandlers[ inputRasterBandsIdx ].reset( 
new double[ blockElementsNumber ] );
 
 1683         outDoubleBuffers[ inputRasterBandsIdx ] = outDoubleBuffersHandlers[ inputRasterBandsIdx ].get();
 
 1687           outputMinValue[ inputRasterBandsIdx ],
 
 1688           outputMaxValue[ inputRasterBandsIdx ] );        
 
 1693       boost::scoped_array< unsigned char > blockBuffer( 
new unsigned char[ maxBlocksSizesBytes ] );
 
 1695       unsigned int elementIdx = 0;
 
 1696       boost::numeric::ublas::matrix< double > pixelValues( inputRasterBandsSize, 1 );
 
 1697       boost::numeric::ublas::matrix< double > remappedPixelValues( inputRasterBandsSize, 1 );
 
 1698       bool elementIsValid = 
false;
 
 1718             for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1719               ++inputRasterBandsIdx )
 
 1721               const unsigned int& inBandIdx = inputRasterBands[ inputRasterBandsIdx ];
 
 1724               inBandPtr->
read( blkX, blkY, blockBuffer.get() );
 
 1727                 blockElementsNumber,
 
 1728                 inDoubleBuffers[ inputRasterBandsIdx ] );            
 
 1735             for( elementIdx = 0 ; elementIdx < blockElementsNumber ; ++elementIdx )
 
 1737               elementIsValid = 
true;
 
 1739               for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1740                 ++inputRasterBandsIdx )
 
 1742                 if( inDoubleBuffers[ inputRasterBandsIdx ][ elementIdx ] == 
 
 1743                   inputBandsNoDataValues[ inputRasterBandsIdx ] )
 
 1745                   elementIsValid = 
false;
 
 1750                   pixelValues( inputRasterBandsIdx, 0 ) = 
 
 1751                     inDoubleBuffers[ inputRasterBandsIdx ][ elementIdx ];
 
 1755               if( elementIsValid )
 
 1759                 remappedPixelValues = boost::numeric::ublas::prod( remapMatrix, pixelValues );
 
 1763                 for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1764                   ++inputRasterBandsIdx )
 
 1766                   outDoubleBuffers[ inputRasterBandsIdx ][ elementIdx ] =
 
 1768                       outputMinValue[ inputRasterBandsIdx ],
 
 1770                         outputMaxValue[ inputRasterBandsIdx ],
 
 1771                         remappedPixelValues( inputRasterBandsIdx, 0 )
 
 1782             for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1783               ++inputRasterBandsIdx )
 
 1789                 blockBuffer.get() );              
 
 1791               outBandPtr->
write( blkX, blkY, blockBuffer.get() );          
 
 1803       const std::vector< unsigned int >& inputRasterBands, 
 
 1804       const boost::numeric::ublas::matrix< double >& remapMatrix,
 
 1806       const unsigned int maxThreads )
 
 1816       if( remapMatrix.size1() != inputRasterBands.size() )
 
 1820       if( remapMatrix.size2() != inputRasterBands.size() )
 
 1839       bool useOptimizedRemap = 
true;
 
 1842         for( 
unsigned int inputRasterBandsIdx = 0 ; inputRasterBandsIdx <
 
 1895             useOptimizedRemap = 
false;
 
 1903       if( useOptimizedRemap )
 
 1906         if( ! rasterBlocksStatus.
reset( 
 
 1913         for( 
unsigned int row = 0 ; row < rasterBlocksStatus.
getLinesNumber() ;
 
 1919             rasterBlocksStatus( row, col ) = 
false;
 
 1934         if( maxThreads == 1 )
 
 1942           boost::thread_group threads;
 
 1944           for( 
unsigned int threadIdx = 0 ; threadIdx < threadsNumber ;
 
 1958         const unsigned int inputRasterBandsSize = inputRasterBands.size();
 
 1961         boost::numeric::ublas::matrix< double > pixelValues( inputRasterBands.size(), 1 );
 
 1962         boost::numeric::ublas::matrix< double > remappedPixelValues( inputRasterBands.size(), 1 );
 
 1963         std::vector< double > inputNoDataValues( inputRasterBandsSize );
 
 1964         std::vector< double > outputNoDataValues( inputRasterBandsSize );
 
 1965         std::vector< double > outputMinValue( inputRasterBandsSize );
 
 1966         std::vector< double > outputMaxValue( inputRasterBandsSize );        
 
 1967         unsigned int inputRasterBandsIdx = 0;
 
 1968         unsigned int row = 0;
 
 1969         unsigned int col = 0;
 
 1970         bool pixelIsValid = 
false;
 
 1972         for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1973           ++inputRasterBandsIdx )
 
 1975           if( inputRasterBands[ inputRasterBandsIdx ] >= inputRaster.
getNumberOfBands() )
 
 1980           inputNoDataValues[ inputRasterBandsIdx ] = inputRaster.
getBand( 
 
 1983           outputNoDataValues[ inputRasterBandsIdx ] = outputRaster.
getBand( 
 
 1988             outputMinValue[ inputRasterBandsIdx ],
 
 1989             outputMaxValue[ inputRasterBandsIdx ] );
 
 1992         for( row = 0 ; row < nRows ; ++row )
 
 1994           for( col = 0 ; col < nCols ; ++col )
 
 1996             pixelIsValid = 
true;
 
 1998             for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 1999               ++inputRasterBandsIdx )
 
 2001               inputRaster.
getValue( col, row, pixelValues( inputRasterBandsIdx, 0 ),
 
 2002                 inputRasterBands[ inputRasterBandsIdx ] );
 
 2004               if( pixelValues( inputRasterBandsIdx, 0 ) == inputNoDataValues[ inputRasterBandsIdx ] )
 
 2006                 pixelIsValid = 
false;
 
 2013               remappedPixelValues = boost::numeric::ublas::prod( remapMatrix, pixelValues );
 
 2015               for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 2016                 ++inputRasterBandsIdx )
 
 2022                     outputMinValue[ inputRasterBandsIdx ]
 
 2025                       outputMaxValue[ inputRasterBandsIdx ]
 
 2027                       remappedPixelValues( inputRasterBandsIdx, 0 )
 
 2030                   inputRasterBandsIdx );
 
 2035               for( inputRasterBandsIdx = 0 ; inputRasterBandsIdx < inputRasterBandsSize ;
 
 2036                 ++inputRasterBandsIdx )
 
 2038                 outputRaster.
setValue( col, row, outputNoDataValues[ inputRasterBandsIdx ], 
 
 2039                   inputRasterBandsIdx );
 
double GetDigitalNumberBandMax(std::string bandName)
Returns the maximum digital number of a given sensor/band. 
 
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell. 
 
boost::mutex * m_mutexPtr
 
double * m_stdDevValuePtr
 
boost::mutex * m_mutexPtr
 
virtual std::complex< double > getMinValue(unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const 
It computes and returns the minimum occurring value in a window of the band. 
 
void reset()
Reset the internal state (all internal pointed objects are deleted). 
 
te::rst::Raster * m_outputRasterPtr
 
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type. 
 
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value. 
 
Matrix< bool > * m_rasterBlocksStatusPtr
 
unsigned int getRow() const 
Returns the current row in iterator. 
 
A raster band description. 
 
double * m_pixelsNumberValuePtr
 
A class that models the description of a dataset. 
 
unsigned int getNumberOfColumns() const 
Returns the raster number of columns. 
 
int m_nblocksx
The number of blocks in x. 
 
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band. 
 
bool GetMeanValue(const te::rst::Band &band, const unsigned int maxThreads, double &meanValue)
Get the mean of band pixel values. 
 
int m_nblocksy
The number of blocks in y. 
 
This class implements and iterator to "navigate" over a raster, with a predefined number of bands...
 
virtual std::auto_ptr< DataSourceTransactor > getTransactor()=0
It returns an object that can execute transactions in the context of a data source. 
 
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. 
 
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. 
 
#define MIN(a, b)
Macro that returns min between two values. 
 
void release(std::auto_ptr< te::da::DataSource > &dataSourcePtr, std::auto_ptr< te::da::DataSourceTransactor > &transactorPtr, std::auto_ptr< te::da::DataSet > &dataSetPtr, std::auto_ptr< te::rst::Raster > &rasterPtr)
Relase the internal state and give the ownership to the given pointers. 
 
virtual void read(int x, int y, void *buffer) const =0
It reads a data block to the specified buffer. 
 
Matrix< bool > * m_rasterBlocksStatusPtr
 
boost::mutex * m_mutexPtr
 
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
 
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max(). 
 
te::rst::Band const * m_inputBandPtr
 
double GetSpectralBandMax(std::string bandName)
Returns the maximum reflectance value of a given sensor/band. 
 
#define MAX(a, b)
Macro that returns max between two values. 
 
Raster Processing functions. 
 
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. 
 
std::vector< unsigned int > const * m_inputRasterBandsPtr
 
te::common::AccessPolicy getAccessPolicy() const 
Returns the raster access policy. 
 
boost::mutex * m_mutexPtr
 
bool TERPEXPORT Copy2DiskRaster(const te::rst::Raster &inputRaster, const std::string &fileName)
Create a new raster into a GDAL datasource. 
 
TECOMMONEXPORT unsigned int GetPhysProcNumber()
Returns the number of physical processors. 
 
te::rst::Band const * m_inputBand1Ptr
 
A point with x and y coordinate values. 
 
bool NormalizeRaster(te::rst::Raster &inraster, double nmin, double nmax)
Normalizes one raster in a given interval. 
 
An abstract class for raster data strucutures. 
 
static RasterIterator begin(Raster *r, const std::vector< unsigned int > &bands)
Returns an iterator referring to the first value. 
 
unsigned int getNumberOfRows() const 
Returns the raster number of rows. 
 
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. 
 
static std::auto_ptr< DataSource > make(const std::string &dsType)
 
BandProperty * getProperty()
Returns the band property. 
 
int m_blkw
Block width (pixels). 
 
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster. 
 
std::pair< double, double > GetDigitalNumberBandInfo(std::string bandName)
Returns the maximun and minimum digital numbers of a given sensor/band. 
 
te::rst::Raster const * m_inputRasterPtr
 
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module. 
 
virtual void write(int x, int y, void *buffer)=0
It writes a data block from the specified buffer. 
 
virtual std::complex< double > getMaxValue(unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const 
It computes and returns the maximum occurring value in a window of the band. 
 
void Convert2DoublesVector(void *inputVector, const int inputVectorDataType, unsigned int inputVectorSize, double *outputVector)
Convert vector elements. 
 
te::rst::Band const * m_inputBand2Ptr
 
bool EigenVectors(const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &eigenVectorsMatrix, boost::numeric::ublas::matrix< T > &eigenValuesMatrix)
Computes the eigenvectors of a given matrix. 
 
void GetMeanValueThread(GetMeanValueThreadParams *paramsPtr)
 
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. 
 
Matrix< bool > * m_rasterBlocksStatusPtr
 
Grid * getGrid()
It returns the raster grid. 
 
std::vector< te::gm::Point * > GetRandomPointsInRaster(const te::rst::Raster &inputRaster, unsigned int numberOfPoints)
Creates a vector of random positions (points) inside the raster. 
 
te::rst::Band const * m_inputBandPtr
 
void reset()
Reset (clear) the active instance data. 
 
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const 
Returns the attribute value of a band of a cell. 
 
void RemapValuesThread(RemapValuesThreadParams *paramsPtr)
 
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value. 
 
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. 
 
int getSRID() const 
Returns the raster spatial reference system identifier. 
 
double * m_pixelsNumberValuePtr
 
double GetSpectralBandMin(std::string bandName)
Returns the minimum reflectance value of a given sensor/band. 
 
bool GetInverseMatrix(const boost::numeric::ublas::matrix< T > &inputMatrix, boost::numeric::ublas::matrix< T > &outputMatrix)
Matrix inversion. 
 
void gridToGeo(const double &col, const double &row, double &x, double &y) const 
Get the spatial location of a grid point. 
 
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. 
 
static RasterIterator end(Raster *r, const std::vector< unsigned int > &bands)
Returns an iterator referring to after the end of the iterator. 
 
te::rst::Raster * getRasterPtr()
Returns a pointer the the handled raster instance or NULL if no instance is handled. 
 
unsigned int getColumn() const 
Returns the current column in iterator. 
 
int getType() const 
It returns the data type of the elements in the band. 
 
Matrix< bool > * m_rasterBlocksStatusPtr
 
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. 
 
double * m_covarianceValuePtr
 
int m_blkh
Block height (pixels). 
 
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. 
 
boost::numeric::ublas::matrix< double > const * m_remapMatrixPtr
 
void GetCovarianceValueThread(GetCovarianceValueThreadParams *paramsPtr)
 
double * m_pixelsNumberValuePtr
 
virtual int getBlockSize() const 
It returns the number of bytes ocuppied by a data block. 
 
void GetStdDevValueThread(GetStdDevValueThreadParams *paramsPtr)
 
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.