| 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/TePDIParallelSegmenter.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 TEPDIPARALELLSEGMENTER_HPP
    00026   #define TEPDIPARALELLSEGMENTER_HPP
    00027
    00028   #include "TePDIAlgorithm.hpp"
    00029   #include "TePDIMatrix.hpp"
    00030   #include "TePDIParaSegSegmentsBlock.hpp"
    00031   #include "TePDIParaSegSegment.hpp"
    00032   #include "TePDIParaSegStrategy.hpp"
    00033
    00034   #include "../kernel/TeMutex.h"
    00035   #include "../kernel/TeThreadSignal.h"
    00036
    00081   class PDI_DLL TePDIParallelSegmenter : public TePDIAlgorithm
    00082   {
    00083     public :
    00084
    00085       TePDIParallelSegmenter();
    00086
    00087       ~TePDIParallelSegmenter();
    00088
    00089       // Overloaded
    00090       bool CheckParameters( const TePDIParameters& parameters ) const;
    00091
    00092     protected :
    00093
    00095       typedef TePDIMatrix< TePDIParaSegSegmentsBlock > SegmentsBlocksMatrixT;
    00096
    00100       class SegmenterThreadEntryParams
    00101       {
    00102         public :
    00104           TeRaster* inputRasterPtr_;
    00105
    00107           std::vector< unsigned int > const* inputChannelsVecPtr_;
    00108
    00110           SegmentsBlocksMatrixT* segsBlocksMatrixPtr_;
    00111
    00113           TeMutex* mutexPtr_;
    00114
    00116           TePDIParameters const* stratParamsPtr_;
    00117
    00119           std::string const* stratNamePtr_;
    00120
    00122           bool volatile* abortSegmentationFlagPtr_;
    00123
    00126           TePDIParaSegSegment::SegIdDataType volatile* segmentsIdsCounterPtr_;
    00127
    00129           TeThreadSignal* signalPtr_;
    00130
    00132           bool progressEnabled_;
    00133
    00135           bool mergeAdjacentBlocks_;
    00136
    00137           SegmenterThreadEntryParams()
    00138           {
    00139             inputRasterPtr_ = 0;
    00140             inputChannelsVecPtr_ = 0;
    00141             segsBlocksMatrixPtr_ = 0;
    00142             mutexPtr_ = 0;
    00143             stratParamsPtr_ = 0;
    00144             stratNamePtr_ = 0;
    00145             abortSegmentationFlagPtr_ = 0;
    00146             segmentsIdsCounterPtr_ = 0;
    00147             signalPtr_ = 0;
    00148             progressEnabled_ = false;
    00149             mergeAdjacentBlocks_ = false;
    00150           }
    00151
    00152           ~SegmenterThreadEntryParams() {};
    00153       };
    00154
    00158       class GroupDataThreadEntryParams
    00159       {
    00160         public :
    00161
    00163           TeRaster* outputRasterPtr_;
    00164
    00166           SegmentsBlocksMatrixT* segsBlocksMatrixPtr_;
    00167
    00169           TeMutex* mutexPtr_;
    00170
    00172           TePDIParameters const* stratParamsPtr_;
    00173
    00175           std::string const* stratNamePtr_;
    00176
    00178           bool volatile* abortSegmentationFlagPtr_;
    00179
    00182           TeThreadSignal* signalPtr_;
    00183
    00186           TePDIParaSegSegment::SegIdDataType volatile* segmentsIdsCounterPtr_;
    00187
    00190           bool waitForSignals_;
    00191
    00193           bool progressEnabled_;
    00194
    00196           bool mergeAdjacentBlocks_;
    00197
    00198           GroupDataThreadEntryParams()
    00199           {
    00200             outputRasterPtr_ = 0;
    00201             segsBlocksMatrixPtr_ = 0;
    00202             mutexPtr_ = 0;
    00203             stratParamsPtr_ = 0;
    00204             stratNamePtr_ = 0;
    00205             abortSegmentationFlagPtr_ = 0;
    00206             signalPtr_ = 0;
    00207             segmentsIdsCounterPtr_ = 0;
    00208             waitForSignals_ = true;
    00209             progressEnabled_ = false;
    00210             mergeAdjacentBlocks_ = false;
    00211           }
    00212
    00213           ~GroupDataThreadEntryParams() {};
    00214       };
    00215
    00216       // Overloaded
    00217       bool RunImplementation();
    00218
    00219       // Overloaded
    00220       void ResetState( const TePDIParameters& params );
    00221
    00227       static bool segmenterThreadEntry(void* paramsPtr);
    00228
    00234       static bool groupDataThreadEntry(void* paramsPtr);
    00235
    00245       static bool flushBlock( TePDIParaSegSegmentsBlock& currBlock,
    00246         TeRaster& outRaster, TePDIPIManager& progress );
    00247
    00259       bool calcBestBlockSize( const unsigned int totalImageLines,
    00260         const unsigned int totalImageCols, const unsigned int minBlockPixels,
    00261         const unsigned int maxBlockPixels, unsigned int& blockWidth,
    00262         unsigned int& blockHeight ) const;
    00263
    00264   };
    00265
    00266
    00267 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines