| 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/TePDIMMIOMatching.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
    00025 #ifndef TEPDIMMIOMATCHING_HPP
    00026   #define TEPDIMMIOMATCHING_HPP
    00027
    00028   #include "TePDIAlgorithm.hpp"
    00029   #include "TePDIMtxDoubleAdpt.hpp"
    00030
    00031   #include "../kernel/TeThreadJobsManager.h"
    00032   #include "../kernel/TeMutex.h"
    00033
    00034   #include <list>
    00035
    00153   class PDI_DLL TePDIMMIOMatching : public TePDIAlgorithm {
    00154     public :
    00155
    00157       enum FeatMatchingMethod
    00158       {
    00160         NormCrossCorrMethod
    00161       };
    00162
    00163       TePDIMMIOMatching();
    00164
    00165       ~TePDIMMIOMatching();
    00166
    00167       // Overloaded
    00168       bool CheckParameters( const TePDIParameters& parameters ) const;
    00169
    00170     protected :
    00171
    00174       typedef TePDIMatrix< unsigned char > MaskMatrixT;
    00175
    00177       struct MaximasListNodeT
    00178       {
    00180         unsigned int x_;
    00182         unsigned int y_;
    00184         double dirVariance_;
    00185       };
    00186
    00189       typedef std::list< MaximasListNodeT > MaximasListT;
    00190
    00195       typedef std::pair< unsigned int, unsigned int > MaximasMapNodeT;
    00196
    00199       typedef std::multimap< double, MaximasMapNodeT > MaximasMapT;
    00200
    00203       class PDI_DLL LoadImageParams
    00204       {
    00205         public :
    00206
    00208           TePDITypes::TePDIRasterPtrType input_image_ptr_;
    00209
    00212           TePDITypes::TePDIRasterPtrType mask_image_ptr_;
    00213
    00214           unsigned int input_image_channel_;
    00215
    00216           TePDIMtxDoubleAdptInt* img_matrix_ptr_;
    00217
    00218           TePDIMtxDoubleAdptInt* img_matrix_ds_ptr_;
    00219
    00220           TePDIMtxDoubleAdptInt* img_matrix_us_ptr_;
    00221
    00223           MaskMatrixT* mask_matrix_ptr_;
    00224
    00226           unsigned int in_box_x_off_;
    00227
    00229           unsigned int in_box_y_off_;
    00230
    00232           unsigned int in_box_nlines_;
    00233
    00235           unsigned int in_box_ncols_;
    00236
    00238           bool progress_enabled_;
    00239
    00241           TeMutex* glb_mem_lock_ptr_;
    00242
    00244           double origImgXRescFact_;
    00245
    00247           double origImgYRescFact_;
    00248
    00250           double moravecDownSampleFactor_;
    00251
    00253           double moravecUpSampleFactor_;
    00254
    00256           volatile bool returnValue_;
    00257
    00259           bool generateUpsampledImage_;
    00260
    00262           bool generateDownsampledImage_;
    00263
    00264           LoadImageParams()
    00265           : input_image_channel_( 0 ), img_matrix_ptr_( 0 ),
    00266             img_matrix_ds_ptr_( 0 ), img_matrix_us_ptr_( 0 ),
    00267             mask_matrix_ptr_( 0 ), in_box_x_off_( 0 ),
    00268             in_box_y_off_( 0 ), in_box_nlines_( 0 ),
    00269             in_box_ncols_( 0 ), progress_enabled_( false ),
    00270             glb_mem_lock_ptr_( 0 ),
    00271             origImgXRescFact_( 1 ),
    00272             origImgYRescFact_( 1 ), moravecDownSampleFactor_( 1 ),
    00273             moravecUpSampleFactor_( 1 ), returnValue_( false ),
    00274             generateUpsampledImage_( false ), generateDownsampledImage_( false )
    00275           {};
    00276
    00277           ~LoadImageParams() {};
    00278       };
    00279
    00280       class PDI_DLL ExtractLocalMaximasParams
    00281       {
    00282         public :
    00283
    00285           TePDIMtxDoubleAdptInt const* imgMatrixPtr_;
    00286
    00289           MaximasListT* outMaximasListPtr_;
    00290
    00291           unsigned int moravecWindowSize_;
    00292
    00293           unsigned int maximasNumber_;
    00294
    00296           unsigned seachSubImagesNmb_; // Number of sub-images to seach.
    00297
    00298           //Job return value.
    00299           volatile bool returnValue_;
    00300
    00302           bool progressEnabled_;
    00303
    00305           TeMutex* glbMutexptr_;
    00306
    00308           MaskMatrixT const* maskMatrixPtr_;
    00309
    00310           ExtractLocalMaximasParams()
    00311           : imgMatrixPtr_( 0 ), outMaximasListPtr_( 0 ),
    00312             moravecWindowSize_( 0 ), maximasNumber_( 0 ),
    00313             seachSubImagesNmb_( 0 ), returnValue_( false ),
    00314             progressEnabled_( false ), glbMutexptr_( 0 ),
    00315             maskMatrixPtr_( 0 )
    00316           {};
    00317
    00318           ~ExtractLocalMaximasParams() {};
    00319       };
    00320
    00321       struct GenerateCorrelationFeaturesParams
    00322       {
    00324         TePDIMtxDoubleAdptInt const* imgMatrixPtr_;
    00325
    00327         MaximasListT const* inMaximasListPtr_;
    00328
    00330         TePDIMatrix< double >* featMtxPtr_;
    00331
    00333         volatile bool returnValue_;
    00334
    00335         /* A mutex object pointer to sync large memory allocations */
    00336         TeMutex* glbMemLockPtr_; // To sync large memory allocations
    00337
    00339         unsigned int corrWindowsWidth_;
    00340
    00342         bool progressEnabled_;
    00343
    00347         bool normalizeWindows_;
    00348       };
    00349
    00350       class CalcCCorrelationMtxParams
    00351       {
    00352         public :
    00354           TePDIMatrix< double > const* img1FeatMtxPtr_;
    00355
    00357           TePDIMatrix< double > const* img2FeatMtxPtr_;
    00358
    00361           TePDIMatrix<double>* matchMatrixPtr_;
    00362
    00365           double* matchMatrixMinPtr_;
    00366
    00369           double* matchMatrixMaxPtr_;
    00370
    00372           bool progressEnabled_;
    00373
    00375           TeMutex* glbMutexptr_;
    00376
    00379           volatile bool returnValue_;
    00380
    00381           CalcCCorrelationMtxParams()
    00382           : img1FeatMtxPtr_( 0 ), img2FeatMtxPtr_( 0 ), matchMatrixPtr_( 0 ),
    00383           matchMatrixMinPtr_( 0 ),
    00384           matchMatrixMaxPtr_( 0 ),
    00385           progressEnabled_( false ), glbMutexptr_( 0 ), returnValue_( false )
    00386           {};
    00387
    00388           ~CalcCCorrelationMtxParams() {};
    00389       };
    00390
    00392       const double moravecDownSampleFactor_;
    00393
    00395       const double moravecUpSampleFactor_;
    00396
    00398       const double moravecRepeatabilityMinTolerance_;
    00399
    00401       TeThreadJobsManager jobsMan_;
    00402
    00404       TeMutex globalMutex_;
    00405
    00406       // Overloaded
    00407       bool RunImplementation();
    00408
    00409       // Overloaded
    00410       void ResetState( const TePDIParameters& params );
    00411
    00418       static void loadImage( void * paramsPtr );
    00419
    00425       static void createImgMatrix( TeDataType dataType,
    00426         TeSharedPtr< TePDIMtxDoubleAdptInt >& matrixPtr );
    00427
    00434       static void extractLocalMaximas( void * paramsPtr );
    00435
    00453       static bool extractLocalMaximas(
    00454         TePDIMtxDoubleAdptInt const* imgMatrixPtr,
    00455         MaskMatrixT const* maskMatrixPtr,
    00456         const unsigned int& xStart, const unsigned int& yStart,
    00457         const unsigned int& width, const unsigned int& height,
    00458         TePDIMatrix< double >& bufferMatrix,
    00459         const unsigned int& moravecWindowSize,
    00460         const unsigned int& maximasNumber,
    00461         MaximasListT& outMaximasList,
    00462         TePDIPIManager& progress );
    00463
    00477       void moravecRepeatability( const MaximasListT& inputList,
    00478         const MaximasListT& constraintList,
    00479         unsigned int constraintImageWidth,
    00480         unsigned int constraintImageHeight,
    00481         double moravecRepeatabilityMinTolerance,
    00482         double moravecReSampleFactor,
    00483         MaximasListT& outputList );
    00484
    00490       static void generateCorrelationFeatures( void * paramsPtr );
    00491
    00504       bool matchFeatures( FeatMatchingMethod matching_method,
    00505         const TePDIMatrix< double >& img1featMtx,
    00506         const MaximasListT& img1_maximas_list,
    00507         const TePDIMatrix< double >& img2featMtx,
    00508         const MaximasListT& img2_maximas_list,
    00509         TeCoordPairVect& tiePointsVec,
    00510         std::vector< double >& tiePointsWeights );
    00511
    00517       static void calcCCorrelationMtx( void * paramsPtr );
    00518
    00526       static void matrix2Tiff(
    00527         const TePDIMtxDoubleAdptInt& input_matrix,
    00528         const std::string& out_file_name,
    00529         const MaximasListT& maxima_points = MaximasListT() );
    00530
    00539       static void matrix2Tiff(
    00540         const TePDIMtxDoubleAdptInt& input_matrix,
    00541         const std::string& out_file_name,
    00542         const TeCoordPairVect& tiepoints,
    00543         bool usePt1 );
    00544
    00552       static void doublesMatrix2Tiff(
    00553         const TePDIMatrix< double >& input_matrix,
    00554         const std::string& out_file_name,
    00555         const MaximasListT& maxima_points = MaximasListT() );
    00556
    00569       static void features2Tiff(
    00570         unsigned int corr_window_width,
    00571         const MaximasListT& img_maxima_points,
    00572         TePDIMatrix< double >& img_features_matrix,
    00573         const std::string& filenameaddon );
    00574
    00587       static bool bicubicResampleMatrix( const TePDIMtxDoubleAdptInt& inputMatrix,
    00588         unsigned int outLines, unsigned int outCols, bool progressEnabled,
    00589         TeMutex& globalMutex, double outMinValue, double outMaxValue,
    00590         TePDIMtxDoubleAdptInt& outputMatrix );
    00591
    00600       static bool generateMaximasRaster(
    00601         const TePDIMtxDoubleAdptInt& inputMatrix,
    00602         const MaximasListT& maximaPoints,
    00603         TeRaster& outRaster );
    00604   };
    00605
    00606
    00607 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines