Raster region growing segmenter strategy. More...
#include <SegmenterRegionGrowingStrategy.h>
  
 Classes | |
| class | BaatzMerger | 
| Baatz based Segments merger.  More... | |
| class | MeanMerger | 
| Mean based Segments merger.  More... | |
| class | Merger | 
| Segments merger.  More... | |
| class | Parameters | 
| Segmenter Parameters.  More... | |
Public Member Functions | |
| bool | execute (SegmenterIdsManager &segmenterIdsManager, const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< double > &inputRasterGains, const std::vector< double > &inputRasterOffsets, te::rst::Raster &outputRaster, const unsigned int outputRasterBand, const bool enableProgressInterface) throw ( te::rp::Exception ) | 
| Executes the segmentation strategy.  More... | |
| double | getMemUsageEstimation (const unsigned int bandsToProcess, const unsigned int pixelsNumber) const | 
| Returns a memory estimation (bytes).  More... | |
| unsigned int | getOptimalBlocksOverlapSize () const | 
| Returns a optimal blocks overlap size (number of border pixels overlapped between blocks, under one direction).  More... | |
| bool | initialize (SegmenterStrategyParameters const *const strategyParams) throw ( te::rp::Exception ) | 
| Initialize the segmentation strategy.  More... | |
| void | reset () | 
| Clear all internal allocated resources and go back to the initial not-initialized state.  More... | |
| SegmenterRegionGrowingStrategy () | |
| ~SegmenterRegionGrowingStrategy () | |
Protected Types | |
| typedef Matrix < SegmenterSegmentsBlock::SegmentIdDataType >  | SegmentsIdsMatrixT | 
| Internal segments ids matrix type definition.  More... | |
Protected Member Functions | |
| void | exportSegs2Tif (const SegmentsIdsMatrixT &segmentsIds, bool normto8bits, const std::string &fileName) | 
| Export the segments IDs to a tif file.  More... | |
| bool | initializeSegments (SegmenterIdsManager &segmenterIdsManager, const te::rst::Raster &inputRaster, const std::vector< unsigned int > &inputRasterBands, const std::vector< double > &inputRasterGains, const std::vector< double > &inputRasterOffsets) | 
| Initialize the segment objects container and the segment IDs container.  More... | |
| unsigned int | mergeSegments (const SegmenterRegionGrowingSegment::FeatureType disimilarityThreshold, SegmenterIdsManager &segmenterIdsManager, Merger &merger, const bool enablelocalMutualBestFitting, SegmenterRegionGrowingSegment *auxSeg1Ptr, SegmenterRegionGrowingSegment *auxSeg2Ptr, SegmenterRegionGrowingSegment *auxSeg3Ptr) | 
| Merge closest segments.  More... | |
| unsigned int | mergeSmallSegments (const unsigned int minSegmentSize, SegmenterIdsManager &segmenterIdsManager, Merger &merger, SegmenterRegionGrowingSegment *auxSeg1Ptr, SegmenterRegionGrowingSegment *auxSeg2Ptr) | 
| Merge only small segments to their closest segment.  More... | |
Static Protected Member Functions | |
| static void | getTouchingEdgeLength (const SegmentsIdsMatrixT &segsIds, const unsigned int &xStart, const unsigned int &yStart, const unsigned int &xBound, const unsigned int &yBound, const SegmenterSegmentsBlock::SegmentIdDataType &id1, const SegmenterSegmentsBlock::SegmentIdDataType &id2, unsigned int &edgeLength1, unsigned int &edgeLength2) | 
| Returns the count of points from region 1 (with ID1) touching the region 2 (with ID2).  More... | |
Protected Attributes | |
| bool | m_isInitialized | 
| true if this instance is initialized.  More... | |
| SegmenterRegionGrowingStrategy::Parameters | m_parameters | 
| Internal execution parameters.  More... | |
| SegmentsIdsMatrixT | m_segmentsIdsMatrix | 
| A internal segments IDs matrix that can be reused on each strategy execution.  More... | |
| SegmenterRegionGrowingSegmentsPool | m_segmentsPool | 
| A pool of segments that can be reused on each strategy execution.  More... | |
Raster region growing segmenter strategy.
Definition at line 50 of file SegmenterRegionGrowingStrategy.h.
      
  | 
  protected | 
Internal segments ids matrix type definition.
Definition at line 134 of file SegmenterRegionGrowingStrategy.h.
| te::rp::SegmenterRegionGrowingStrategy::~SegmenterRegionGrowingStrategy | ( | ) | 
Definition at line 647 of file SegmenterRegionGrowingStrategy.cpp.
References reset().
| te::rp::SegmenterRegionGrowingStrategy::SegmenterRegionGrowingStrategy | ( | ) | 
Definition at line 642 of file SegmenterRegionGrowingStrategy.cpp.
References m_isInitialized.
      
  | 
  virtual | ||||||||||||||||||||||||||||||||||||||||||||
Executes the segmentation strategy.
| segmenterIdsManager | The segments IDs manager to be used when acquiring/releaseing unique segment IDs. | 
| inputRaster | Input raster. | 
| inputRasterBands | Input raster bands. | 
| inputRasterGains | Normalization gain values to be appliet over the respective input raster bands. | 
| inputRasterOffsets | Normalization offset values to be appliet over the respective input raster bands. | 
| outputRaster | Output raster. | 
| outputRasterBand | Output raster band. | 
| enableProgressInterface | Enable the internal strategy to update the progress interface. | 
Implements te::rp::SegmenterStrategy.
Definition at line 720 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterRegionGrowingStrategy::Parameters::BaatzFeaturesType, te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rp::SegmenterRegionGrowingSegmentsPool::getNextSegment(), te::rp::SegmenterRegionGrowingSegmentsPool::getSegsMatrix(), te::rp::SegmenterRegionGrowingSegmentsPool::initialize(), initializeSegments(), te::rp::SegmenterRegionGrowingStrategy::Parameters::m_bandsWeights, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_colorWeight, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_compactnessWeight, m_isInitialized, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_minSegmentSize, m_parameters, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentFeatures, m_segmentsIdsMatrix, m_segmentsPool, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentsSimilarityThreshold, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentsSimIncreaseSteps, te::rp::SegmenterRegionGrowingSegment::m_status, te::rp::SegmenterRegionGrowingStrategy::Parameters::MeanFeaturesType, mergeSegments(), mergeSmallSegments(), te::rp::Matrix< TemplateElementType >::reset(), TERP_LOG_AND_THROW, and TERP_TRUE_OR_RETURN_FALSE.
      
  | 
  protected | 
Export the segments IDs to a tif file.
| segmentsIds | The output segment ids container. | 
| normto8bits | If true, a 8 bits file will be generated. | 
| fileName | The output tif file name. | 
Definition at line 1675 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rst::RasterFactory::make(), te::rst::Raster::setValue(), TERP_TRUE_OR_THROW, te::dt::UCHAR_TYPE, and te::dt::UINT32_TYPE.
      
  | 
  virtual | 
Returns a memory estimation (bytes).
This parameter is used by the segmenter to guess the sub-image blocks size.
| bandsToProcess | The number of input raster bands that will be processed at the strategy execution time. | 
| pixelsNumber | The number of pixels. | 
Implements te::rp::SegmenterStrategy.
Definition at line 1021 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterRegionGrowingStrategy::Parameters::BaatzFeaturesType, m_isInitialized, m_parameters, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentFeatures, te::rp::SegmenterRegionGrowingStrategy::Parameters::MeanFeaturesType, TERP_LOG_AND_THROW, and TERP_TRUE_OR_THROW.
      
  | 
  virtual | 
Returns a optimal blocks overlap size (number of border pixels overlapped between blocks, under one direction).
Implements te::rp::SegmenterStrategy.
Definition at line 1100 of file SegmenterRegionGrowingStrategy.cpp.
References m_isInitialized, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_minSegmentSize, m_parameters, and TERP_TRUE_OR_THROW.
      
  | 
  staticprotected | 
Returns the count of points from region 1 (with ID1) touching the region 2 (with ID2).
| segsIds | The segment ids container. | 
| xStart | The upper left X of the bounding box surrounding both regions. | 
| yStart | The upper left Y of the bounding box surrounding both regions. | 
| xBound | The lower right X bound of the bounding box surrounding both regions. | 
| yBound | The lower right Y bound of the bounding box surrounding both regions. | 
| id1 | Region 1 ID. | 
| id2 | Region 2 ID. | 
| edgeLength1 | The touching edge length for the region 1. | 
| edgeLength2 | The touching edge length for the region 2. | 
Definition at line 1739 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), and TERP_DEBUG_TRUE_OR_THROW.
Referenced by te::rp::SegmenterRegionGrowingStrategy::BaatzMerger::getDissimilarity().
      
  | 
  virtual | ||||||||||||||
Initialize the segmentation strategy.
| strategyParams | A pointer to the user given specific segmentation strategy parameters ou NULL if no parameters are present. | 
Implements te::rp::SegmenterStrategy.
Definition at line 652 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterRegionGrowingStrategy::Parameters::BaatzFeaturesType, te::rp::SegmenterRegionGrowingStrategy::Parameters::InvalidFeaturesType, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_bandsWeights, m_isInitialized, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_minSegmentSize, m_parameters, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentFeatures, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentsSimilarityThreshold, reset(), and TERP_TRUE_OR_RETURN_FALSE.
      
  | 
  protected | 
Initialize the segment objects container and the segment IDs container.
| segmenterIdsManager | A segments ids manager to acquire unique segments ids. | 
| inputRaster | The input raster. | 
| inputRasterBands | Input raster bands to use. | 
| segmentsIds | The output segment ids container. | 
Definition at line 1106 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterIdsManager::addFreeIDs(), te::rp::SegmenterRegionGrowingSegment::addNeighborSegment(), BAATZ_CO, BAATZ_EL, BAATZ_SM, BAATZ_SS, BAATZ_ST, BAATZ_SU, te::rp::SegmenterRegionGrowingStrategy::Parameters::BaatzFeaturesType, te::rp::SegmenterRegionGrowingSegment::clearNeighborSegments(), te::rst::Raster::getBand(), te::rp::SegmenterIdsManager::getNewIDs(), te::rp::SegmenterRegionGrowingSegmentsPool::getNextSegment(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Band::getProperty(), te::rst::Raster::getValue(), te::rp::SegmenterRegionGrowingSegment::m_features, te::rp::SegmenterRegionGrowingSegment::m_id, te::rst::BandProperty::m_noDataValue, m_parameters, te::rp::SegmenterRegionGrowingStrategy::Parameters::m_segmentFeatures, m_segmentsIdsMatrix, m_segmentsPool, te::rp::SegmenterRegionGrowingSegment::m_size, te::rp::SegmenterRegionGrowingSegment::m_status, te::rp::SegmenterRegionGrowingSegment::m_xBound, te::rp::SegmenterRegionGrowingSegment::m_xStart, te::rp::SegmenterRegionGrowingSegment::m_yBound, te::rp::SegmenterRegionGrowingSegment::m_yStart, te::rp::SegmenterRegionGrowingStrategy::Parameters::MeanFeaturesType, and TERP_LOG_AND_THROW.
Referenced by execute().
      
  | 
  protected | 
Merge closest segments.
| disimilarityThreshold | The maximum similarity value allowed when deciding when to merge two segments. | 
| segmenterIdsManager | A segments ids manager to acquire unique segments ids. | 
| merger | The merger instance to use. | 
| enablelocalMutualBestFitting | If enabled, a merge only occurs between two segments if the minimum dissimilarity criteria is best fulfilled mutually. | 
| auxSeg1Ptr | A pointer to a valid auxiliar segment that will be used by this method. | 
| auxSeg2Ptr | A pointer to a valid auxiliar segment that will be used by this method. | 
| auxSeg3Ptr | A pointer to a valid auxiliar segment that will be used by this method. | 
Definition at line 1312 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterIdsManager::addFreeIDs(), te::rp::SegmenterRegionGrowingSegment::addNeighborSegment(), te::rp::SegmenterRegionGrowingSegment::clearNeighborSegments(), te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::SegmenterRegionGrowingStrategy::Merger::getDissimilarity(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rp::SegmenterRegionGrowingSegmentsPool::getSegsMatrix(), te::rp::SegmenterRegionGrowingSegment::m_id, te::rp::SegmenterRegionGrowingSegment::m_neighborSegments, te::rp::SegmenterRegionGrowingSegment::m_neighborSegmentsSize, m_segmentsIdsMatrix, m_segmentsPool, te::rp::SegmenterRegionGrowingSegment::m_status, te::rp::SegmenterRegionGrowingSegment::m_xBound, te::rp::SegmenterRegionGrowingSegment::m_xStart, te::rp::SegmenterRegionGrowingSegment::m_yBound, te::rp::SegmenterRegionGrowingSegment::m_yStart, te::rp::SegmenterRegionGrowingStrategy::Merger::mergeFeatures(), te::rp::SegmenterRegionGrowingSegment::removeNeighborSegment(), and te::rp::SegmenterRegionGrowingStrategy::Merger::update().
Referenced by execute().
      
  | 
  protected | 
Merge only small segments to their closest segment.
| minSegmentSize | The minimum segment size (pixels) | 
| similarityThreshold | The minimum similarity value used when deciding when to merge two segments. | 
| segmenterIdsManager | A segments ids manager to acquire unique segments ids. | 
| merger | The merger instance to use. | 
| auxSeg1Ptr | A pointer to a valid auxiliar segment that will be used by this method. | 
| auxSeg2Ptr | A pointer to a valid auxiliar segment that will be used by this method. | 
Definition at line 1511 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterIdsManager::addFreeIDs(), te::rp::SegmenterRegionGrowingSegment::addNeighborSegment(), te::rp::SegmenterRegionGrowingSegment::clearNeighborSegments(), te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::SegmenterRegionGrowingStrategy::Merger::getDissimilarity(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rp::SegmenterRegionGrowingSegmentsPool::getSegsMatrix(), te::rp::SegmenterRegionGrowingSegment::m_id, te::rp::SegmenterRegionGrowingSegment::m_neighborSegments, te::rp::SegmenterRegionGrowingSegment::m_neighborSegmentsSize, m_segmentsIdsMatrix, m_segmentsPool, te::rp::SegmenterRegionGrowingSegment::m_size, te::rp::SegmenterRegionGrowingSegment::m_status, te::rp::SegmenterRegionGrowingSegment::m_xBound, te::rp::SegmenterRegionGrowingSegment::m_xStart, te::rp::SegmenterRegionGrowingSegment::m_yBound, te::rp::SegmenterRegionGrowingSegment::m_yStart, te::rp::SegmenterRegionGrowingStrategy::Merger::mergeFeatures(), te::rp::SegmenterRegionGrowingSegment::removeNeighborSegment(), and te::rp::SegmenterRegionGrowingStrategy::Merger::update().
Referenced by execute().
      
  | 
  virtual | 
Clear all internal allocated resources and go back to the initial not-initialized state.
Implements te::rp::SegmenterStrategy.
Definition at line 712 of file SegmenterRegionGrowingStrategy.cpp.
References te::rp::SegmenterRegionGrowingSegmentsPool::clear(), m_isInitialized, m_parameters, m_segmentsIdsMatrix, m_segmentsPool, te::rp::SegmenterRegionGrowingStrategy::Parameters::reset(), and te::rp::Matrix< TemplateElementType >::reset().
Referenced by initialize(), te::rp::SegmenterRegionGrowingStrategy::Parameters::operator=(), and ~SegmenterRegionGrowingStrategy().
      
  | 
  protected | 
true if this instance is initialized.
Definition at line 286 of file SegmenterRegionGrowingStrategy.h.
Referenced by execute(), getMemUsageEstimation(), getOptimalBlocksOverlapSize(), initialize(), reset(), and SegmenterRegionGrowingStrategy().
      
  | 
  protected | 
Internal execution parameters.
Definition at line 291 of file SegmenterRegionGrowingStrategy.h.
Referenced by execute(), getMemUsageEstimation(), getOptimalBlocksOverlapSize(), initialize(), initializeSegments(), and reset().
      
  | 
  protected | 
A internal segments IDs matrix that can be reused on each strategy execution.
Definition at line 297 of file SegmenterRegionGrowingStrategy.h.
Referenced by execute(), initializeSegments(), mergeSegments(), mergeSmallSegments(), and reset().
      
  | 
  protected | 
A pool of segments that can be reused on each strategy execution.
Definition at line 294 of file SegmenterRegionGrowingStrategy.h.
Referenced by execute(), initializeSegments(), mergeSegments(), mergeSmallSegments(), and reset().