| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/image_processing/TePDIUtils.hpp
Go to the documentation of this file.

    00001 /*
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright  2001, 2002, 2003 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular
    00017 purpose. The library provided hereunder is on an "as is" basis, and the
    00018 authors have no obligation to provide maintenance, support, updates,
    00019 enhancements, or modifications.
    00020 In no event shall INPE be held liable to any party
    00021 for direct, indirect, special, incidental, or consequential damages arising
    00022 out of the use of this library and its documentation.
    00023 */
    00024
    00033 #ifndef TEPDIUTILS_HPP
    00034   #define TEPDIUTILS_HPP
    00035
    00036   #include "TePDIRgbPalette.hpp"
    00037   #include "TePDITypes.hpp"
    00038   #include "TePDIMathFunctions.hpp"
    00039   #include "TePDIInterpolator.hpp"
    00040
    00041   #include "TePDITileIndexer.hpp"
    00042
    00043   #include "../kernel/TeAgnostic.h"
    00044   #include "../kernel/TeRaster.h"
    00045   #include "../kernel/TeDataTypes.h"
    00046   #include "../kernel/TeBox.h"
    00047
    00048   #include <string>
    00049   #include <map>
    00050
    00051
    00058   namespace TePDIUtils
    00059   {
    00063     enum TePDIUtilsMemPol {
    00065       TePDIUtilsAutoMemPol = 1,
    00067       TePDIUtilsRamMemPol = 2,
    00069       TePDIUtilsDiskMemPol = 3
    00070     };
    00071
    00089     PDI_DLL bool TeAllocRAMRaster(
    00090       TePDITypes::TePDIRasterPtrType& template_raster,
    00091       TePDITypes::TePDIRasterPtrType& RAMRaster,
    00092       unsigned int bands, bool force_new_dt, bool force_mm,
    00093       TeDataType pixel_type );
    00094
    00112     PDI_DLL bool TeAllocRAMRaster(
    00113       TePDITypes::TePDIRasterPtrType& RAMRaster,
    00114       unsigned int bands, unsigned int lines, unsigned int columns,
    00115       bool force_mm, TeDataType pixel_type, TePDIRgbPalette* palette );
    00116
    00129     PDI_DLL bool TeAllocRAMRaster( TePDITypes::TePDIRasterPtrType& RAMRaster,
    00130       const TeRasterParams& params, bool force_mm );
    00131
    00140     PDI_DLL bool TeAllocRAMRaster( TePDITypes::TePDIRasterPtrType& RAMRaster,
    00141       const TeRasterParams& params,
    00142       TePDIUtilsMemPol mempol );
    00143
    00151     PDI_DLL bool TeAllocRAMRaster(
    00152       const TeRasterParams& params,
    00153       TePDITypes::TePDIRasterPtrType& rasterPointer );
    00154
    00163     PDI_DLL bool TeRaster2Geotiff(
    00164       const TePDITypes::TePDIRasterPtrType& in_raster,
    00165       const std::string& file_name );
    00166
    00176     PDI_DLL bool TeRaster2Geotiff(
    00177       const TePDITypes::TePDIRasterPtrType& in_raster,
    00178       const std::string& file_name,
    00179       TeDataType pixel_type );
    00180
    00189     PDI_DLL bool TeRaster2Geotiff(
    00190       const TePDITypes::TePDIRasterPtrType& in_raster,
    00191       const std::string& file_name,
    00192       bool enable_progress );
    00193
    00202     PDI_DLL bool TeRaster2RGBGeotiff(
    00203       const TePDITypes::TePDIRasterPtrType& in_raster,
    00204       const std::string& file_name,
    00205       bool enable_progress );
    00206
    00216     PDI_DLL bool TeRaster2Jpeg(
    00217       const TePDITypes::TePDIRasterPtrType& in_raster,
    00218       const std::string& file_name,
    00219       bool enable_progress, unsigned int qualityFactor );
    00220
    00234     PDI_DLL bool TeCopyRasterPixels(
    00235       TePDITypes::TePDIRasterPtrType& source_raster,
    00236       unsigned int source_band,
    00237       TePDITypes::TePDIRasterPtrType& target_raster,
    00238       unsigned int target_band,
    00239       bool discretize_levels,
    00240       bool trunc_levels );
    00241
    00253     PDI_DLL bool TeCopyRasterBands(
    00254       TePDITypes::TePDIRasterPtrType& source_raster,
    00255       TePDITypes::TePDIRasterPtrType& target_raster,
    00256       bool discretize_levels,
    00257       bool trunc_levels );
    00258
    00269     PDI_DLL bool TeGetRasterMinMaxBounds(
    00270       const TePDITypes::TePDIRasterPtrType& raster,
    00271       unsigned int band, double& min, double& max );
    00272
    00279     PDI_DLL unsigned long int TeGetRasterReqMem( TeRasterParams& params );
    00280
    00289     PDI_DLL bool rasterCompare( TePDITypes::TePDIRasterPtrType& raster1,
    00290       TePDITypes::TePDIRasterPtrType& raster2 );
    00291
    00300     PDI_DLL bool IsFloatBand( const TePDITypes::TePDIRasterPtrType& raster,
    00301       unsigned int band );
    00302
    00312     PDI_DLL void MapCoords2RasterIndexes( const TeCoord2D& g_in,
    00313       const TePDITypes::TePDIRasterPtrType& raster, TeCoord2D& g_out );
    00314
    00324     PDI_DLL void MapCoords2RasterIndexes( const TeBox& box_in,
    00325       const TePDITypes::TePDIRasterPtrType& raster, TeBox& box_out );
    00326
    00336     template< typename Geometry >
    00337     void MapCoords2RasterIndexes( const Geometry& g_in,
    00338       const TePDITypes::TePDIRasterPtrType& raster, Geometry& g_out )
    00339     {
    00340         unsigned int nItens = (unsigned int)g_in.size();
    00341
    00342         for (unsigned int i=0; i < nItens ; i++ ) {
    00343                 typename Geometry::value_type e1 = g_in[i];
    00344                 typename Geometry::value_type e2;
    00345
    00346                 MapCoords2RasterIndexes( e1, raster, e2 );
    00347
    00348                 g_out.add( e2 );
    00349         }
    00350     }
    00351
    00360     PDI_DLL void MapRasterIndexes2Coords( const TeCoord2D& g_in,
    00361       const TePDITypes::TePDIRasterPtrType& raster, TeCoord2D& g_out );
    00362
    00371     PDI_DLL void MapRasterIndexes2Coords( const TeBox& g_in,
    00372       const TePDITypes::TePDIRasterPtrType& raster, TeBox& g_out );
    00373
    00382     template< typename Geometry >
    00383     void MapRasterIndexes2Coords( const Geometry& g_in,
    00384       const TePDITypes::TePDIRasterPtrType& raster, Geometry& g_out )
    00385     {
    00386         unsigned int nItens = (unsigned int)g_in.size();
    00387
    00388         for (unsigned int i=0; i < nItens ; i++ ) {
    00389                 typename Geometry::value_type e1 = g_in[i];
    00390                 typename Geometry::value_type e2;
    00391
    00392                 MapRasterIndexes2Coords( e1, raster, e2 );
    00393
    00394                 g_out.add( e2 );
    00395         }
    00396     }
    00397
    00405     PDI_DLL void makeSegmentSet( const TeLinearRing& g_in, TeLineSet& g_out );
    00406
    00413     template< typename Geometry >
    00414     void makeSegmentSet( const Geometry& g_in, TeLineSet& g_out )
    00415     {
    00416       g_out.clear();
    00417
    00418       for ( unsigned int i = 0 ; i < g_in.size() ; i++ ) {
    00419         TeLineSet temp_ls;
    00420
    00421         makeSegmentSet( g_in[i], temp_ls );
    00422
    00423         const unsigned int temp_ls_size = temp_ls.size();
    00424
    00425         for( unsigned int temp_ls_index = 0 ; temp_ls_index < temp_ls_size ;
    00426           ++temp_ls_index ) {
    00427
    00428           g_out.add( temp_ls[ temp_ls_index ] );
    00429         }
    00430        }
    00431     };
    00432
    00440     PDI_DLL bool IsDiscreteLut( const TePDITypes::TePDILutType& lut );
    00441
    00449     PDI_DLL bool buildDetailedBox( TeRaster& raster,
    00450       TePolygon& box_polygon );
    00451
    00460     PDI_DLL bool buildDetailedBox( const TePDITypes::TePDIRasterPtrType& raster,
    00461       TePolygon& box_polygon );
    00462
    00471     PDI_DLL bool buildDetailedBBox( TeRaster& raster,
    00472       TePolygon& box_polygon );
    00473
    00483     PDI_DLL bool buildDetailedBBox( const TePDITypes::TePDIRasterPtrType& raster,
    00484       TePolygon& box_polygon );
    00485
    00499     PDI_DLL bool reprojectRaster( TeRaster& input_raster,
    00500       unsigned int outNLines, unsigned int outNCols,
    00501       TeProjection& target_projection,
    00502       bool enableProgress, bool enableOptimization,
    00503       TeRaster& output_raster );
    00504
    00518     PDI_DLL bool reprojectRaster( TeRaster& input_raster,
    00519       TeProjection& target_projection, double target_resx,
    00520       double target_resy,
    00521       bool enableProgress, bool enableOptimization,
    00522       TeRaster& output_raster );
    00523
    00535     PDI_DLL short TeRelation( const TeCoord2D& c, const TePDITileIndexer& indexer );
    00536
    00547     PDI_DLL void TeSegSetIntersection( const TeLineSet& ls1, const TeLineSet& ls2,
    00548       TePointSet& ps );
    00549
    00556     PDI_DLL TeDataType chooseBestPixelType(
    00557       TePDITypes::TePDIRasterVectorType& rasters );
    00558
    00570     PDI_DLL void getBandMinMaxValues(
    00571       const TePDITypes::TePDIRasterPtrType& raster, unsigned int channel,
    00572       bool progress_enabled, unsigned int sample_step,
    00573       double& min, double& max );
    00574
    00587     PDI_DLL bool convert2MultiBand( const TePDITypes::TePDIRasterPtrType& in_raster,
    00588       bool progress_enabled, TePDITypes::TePDIRasterPtrType& out_raster );
    00589
    00596     PDI_DLL bool compareGeometryPoints( const TeLinearRing& geom1,
    00597       const TeLinearRing& geom2 );
    00598
    00606     template< typename Geometry >
    00607     bool compareGeometryPoints( const Geometry& geom1, const Geometry& geom2 )
    00608     {
    00609       if( geom1.size() == geom2.size() ) {
    00610         const unsigned geom_size = geom1.size();
    00611
    00612         for( unsigned int elem_index = 0 ; elem_index < geom_size ;
    00613           ++elem_index ) {
    00614
    00615           if( ! compareGeometryPoints( geom1[ elem_index ],
    00616             geom2[ elem_index ] ) ) {
    00617
    00618             return false;
    00619           }
    00620         }
    00621
    00622         return true;
    00623       } else {
    00624         return false;
    00625       }
    00626     };
    00627
    00641     PDI_DLL bool resampleRasterByLinsCols(
    00642       const TePDITypes::TePDIRasterPtrType& input_raster,
    00643       const TePDITypes::TePDIRasterPtrType& output_raster,
    00644       unsigned int out_lines,
    00645       unsigned int out_cols,
    00646       bool enable_progress,
    00647       TePDIInterpolator::InterpMethod interpol );
    00648
    00663     PDI_DLL bool resampleRasterByLinsCols(
    00664       const TePDITypes::TePDIRasterPtrType& input_raster,
    00665       const std::vector< unsigned int >& inputBands,
    00666       unsigned int out_lines,
    00667       unsigned int out_cols,
    00668       bool enable_progress,
    00669       TePDIInterpolator::InterpMethod interpol,
    00670       const TePDITypes::TePDIRasterPtrType& output_raster );
    00671
    00684     PDI_DLL bool resampleRasterByRes(
    00685       const TePDITypes::TePDIRasterPtrType& input_raster,
    00686       const TePDITypes::TePDIRasterPtrType& output_raster,
    00687       double x_resolution_ratio,
    00688       double y_resolution_ratio,
    00689       TePDIInterpolator::InterpMethod interpol,
    00690       bool enable_progress );
    00691
    00705     PDI_DLL bool composeRaster(
    00706       const TePDITypes::TePDIRasterVectorType& input_rasters,
    00707       const std::vector< unsigned int >& input_channels,
    00708       TePDITypes::TePDIRasterPtrType& output_raster,
    00709       bool enable_progress );
    00710
    00721     PDI_DLL bool decomposeRaster(
    00722       TeRaster& inputRaster,
    00723       const std::vector< unsigned int >& inputChannels,
    00724       TePDITypes::TePDIRasterVectorType& outputRasters,
    00725       bool enableProgress );
    00726
    00739     PDI_DLL bool loadRaster( const std::string& fileName,
    00740       TePDITypes::TePDIRasterPtrType& memRasterPtr, bool enable_progress );
    00741
    00742   };
    00743
    00748 #endif //TEPDIUTILS_HPP

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines