te::rp::Segmenter Class Reference

Raster segmentation. More...

#include <Segmenter.h>

Inheritance diagram for te::rp::Segmenter:
te::rp::Algorithm

Classes

class  InputParameters
 Segmenter Input Parameters. More...
 
class  OutputParameters
 Segmenter Output Parameters. More...
 
class  SegmenterThreadEntryParams
 The parameters passed to the Segmenter::segmenterthreadEntry method. More...
 

Public Member Functions

bool execute (AlgorithmOutputParameters &outputParams) throw ( te::rp::Exception )
 Executes the algorithm using the supplied parameters. More...
 
const std::string & getErrorMessage () const
 Return the current error message if there is any. More...
 
bool initialize (const AlgorithmInputParameters &inputParams) throw ( te::rp::Exception )
 Initialize the algorithm instance making it ready for execution. More...
 
bool isInitialized () const
 Returns true if the algorithm instance is initialized and ready for execution. More...
 
void reset () throw ( te::rp::Exception )
 Clear all internal allocated objects and reset the algorithm to its initial state. More...
 
 Segmenter ()
 
 ~Segmenter ()
 

Protected Types

typedef te::rp::Matrix< SegmenterSegmentsBlockSegmentsBlocksMatrixT
 

Protected Member Functions

bool calcBestBlockSize (const unsigned int minExapandedBlockPixels, const unsigned int maxExapandedBlockPixels, unsigned int &blocksHOverlapSize, unsigned int &blocksVOverlapSize, unsigned int &nonExpandedBlockWidth, unsigned int &nonExpandedBlockHeight, unsigned int &expandedBlockWidth, unsigned int &expandedBlockHeight) const
 Calc the best sub-image block size for each thread to process. More...
 
bool createCutOffLinesTiff (const std::vector< std::vector< unsigned int > > &imageHorizontalProfiles, const std::vector< unsigned int > &imageHorizontalProfilesCenterLines, const std::vector< std::vector< unsigned int > > &imageVerticalProfiles, const std::vector< unsigned int > &imageVerticalProfilesCenterLines, const std::string &filename)
 
bool genImageHCutOffProfile (const unsigned int profileCenter, const te::rst::Raster &inRaster, const std::vector< unsigned int > &inRasterBands, const unsigned int pixelNeighborhoodSize, const unsigned int tileNeighborhoodSize, const unsigned int profileAntiSmoothingFactor, std::vector< unsigned int > &profile) const
 Generate the horizontal cutOff prifles for the entire image.. More...
 
bool genImageVCutOffProfile (const unsigned int profileCenter, const te::rst::Raster &inRaster, const std::vector< unsigned int > &inRasterBands, const unsigned int pixelNeighborhoodSize, const unsigned int tileNeighborhoodSize, const unsigned int profileAntiSmoothingFactor, std::vector< unsigned int > &profile) const
 Generate the vertical cutOff prifles for the entire image.. More...
 
void setErrorMessage (const std::string &newErrorMessage)
 Set the current error message. More...
 
bool updateBlockCutOffProfiles (const std::vector< std::vector< unsigned int > > &imageHorizontalProfiles, const std::vector< std::vector< unsigned int > > &imageVerticalProfiles, SegmenterSegmentsBlock &segmentsBlock) const
 Update the block cutOff profiles using the full image profiles. More...
 

Static Protected Member Functions

static void segmenterThreadEntry (SegmenterThreadEntryParams *paramsPtr)
 Segmenter thread entry. More...
 

Protected Attributes

Segmenter::InputParameters m_inputParameters
 Segmenter execution parameters. More...
 
bool m_instanceInitialized
 

Detailed Description

Raster segmentation.

Raster segmentation following the choosed segmentation strategy.

Note
The created label image will be written to the raster instance pointed by m_outRasterPtr (in this case the output band must also be passed by m_outRasterBand ); or written to a new raster instance created inside the given data source pointed by m_outDataSourcePtr (in this case the data set name must be supplied - m_outDataSetName ).
See also
te::rp::Segmenter::Parameters For detailed parameters description.
te::rp::SegmenterStrategy For detailed parameters description.

Definition at line 73 of file src/terralib/rp/Segmenter.h.

Member Typedef Documentation

Segments blocks matrix type definition

Definition at line 194 of file src/terralib/rp/Segmenter.h.

Constructor & Destructor Documentation

te::rp::Segmenter::Segmenter ( )

Definition at line 194 of file src/terralib/rp/Segmenter.cpp.

References m_instanceInitialized, and ~Segmenter().

te::rp::Segmenter::~Segmenter ( )
default

Referenced by Segmenter().

Member Function Documentation

bool te::rp::Segmenter::calcBestBlockSize ( const unsigned int  minExapandedBlockPixels,
const unsigned int  maxExapandedBlockPixels,
unsigned int blocksHOverlapSize,
unsigned int blocksVOverlapSize,
unsigned int nonExpandedBlockWidth,
unsigned int nonExpandedBlockHeight,
unsigned int expandedBlockWidth,
unsigned int expandedBlockHeight 
) const
protected

Calc the best sub-image block size for each thread to process.

Parameters
minBlockPixelsThe minimun allowed pixels number for each block (expanded block).
maxBlockPixelsThe maximum allowed pixels number for each block (expanded block).
blocksHOverlapSizeThe blocks horizontal overlap size (number of columns).
blocksVOverlapSizeThe blocks vertical overlap size (number of rows).
nonExpandedBlockWidthThe calculated non-expanded block width (non-expanded block).
nonExpandedBlockHeightThe calculated non-expanded block height (non-expanded block).
expandedBlockWidthThe calculated expanded block width (non-expanded block).
expandedBlockHeightThe calculated expanded block height (non-expanded block).
Returns
true if OK, false on errors.

Definition at line 845 of file src/terralib/rp/Segmenter.cpp.

References te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rp::Segmenter::InputParameters::m_blocksOverlapPercent, m_inputParameters, te::rp::Segmenter::InputParameters::m_inputRasterPtr, and TERP_TRUE_OR_THROW.

Referenced by execute().

bool te::rp::Segmenter::createCutOffLinesTiff ( const std::vector< std::vector< unsigned int > > &  imageHorizontalProfiles,
const std::vector< unsigned int > &  imageHorizontalProfilesCenterLines,
const std::vector< std::vector< unsigned int > > &  imageVerticalProfiles,
const std::vector< unsigned int > &  imageVerticalProfilesCenterLines,
const std::string &  filename 
)
protected
bool te::rp::Segmenter::execute ( AlgorithmOutputParameters outputParams)
throw (te::rp::Exception
)
virtual

Executes the algorithm using the supplied parameters.

Parameters
outputParamsOutput parameters.
Returns
true if OK, false on errors.
Note
A return error string can be obtained via Algorithm::getErrorMessage()

Implements te::rp::Algorithm.

Definition at line 201 of file src/terralib/rp/Segmenter.cpp.

References band, te::rp::SegmenterSegmentsBlock::BlockNotProcessed, te::rp::SegmenterSegmentsBlock::BlockSegmented, calcBestBlockSize(), col, genImageHCutOffProfile(), genImageVCutOffProfile(), te::rst::Raster::getBand(), te::rst::Band::getBlockSize(), te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rst::Raster::getGrid(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::common::GetPhysProcNumber(), te::rst::Band::getProperty(), te::rp::Segmenter::InputParameters::getSegStrategyParams(), te::common::GetTotalPhysicalMemory(), te::common::GetTotalVirtualMemory(), te::common::GetUsedVirtualMemory(), te::rst::Band::getValue(), te::rp::SegmenterStrategy::GradientMerging, te::rst::GrayIdxCInt, te::rp::Segmenter::SegmenterThreadEntryParams::m_abortSegmentationFlagPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_blockProcessedSignalMutexPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_blockProcessedSignalPtr, te::rp::Segmenter::InputParameters::m_blocksOverlapPercent, te::rp::SegmenterSegmentsBlock::m_bottomCutOffProfile, te::rp::Segmenter::InputParameters::m_enableBlockProcessing, te::rp::Segmenter::InputParameters::m_enableProgress, te::rp::Segmenter::InputParameters::m_enableRasterCache, te::rp::Segmenter::SegmenterThreadEntryParams::m_enableStrategyProgress, te::rp::Segmenter::InputParameters::m_enableThreadedProcessing, te::rp::Segmenter::SegmenterThreadEntryParams::m_generalMutexPtr, te::rp::SegmenterSegmentsBlock::m_height, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputParameters, m_inputParameters, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterBandMaxValues, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterBandMinValues, te::rp::Segmenter::InputParameters::m_inputRasterBands, te::rp::Segmenter::InputParameters::m_inputRasterNoDataValues, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterNoDataValues, te::rp::Segmenter::InputParameters::m_inputRasterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterSyncPtr, m_instanceInitialized, te::rp::SegmenterSegmentsBlock::m_leftCutOffProfile, te::rp::Segmenter::InputParameters::m_maxBlockSize, te::rp::Segmenter::SegmenterThreadEntryParams::m_maxInputRasterCachedBlocks, te::rp::Segmenter::InputParameters::m_maxSegThreads, te::rst::BandProperty::m_noDataValue, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputParametersPtr, te::rp::Segmenter::OutputParameters::m_outputRasterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputRasterSyncPtr, te::rp::SegmenterSegmentsBlock::m_rightCutOffProfile, te::rp::Segmenter::OutputParameters::m_rInfo, te::rp::Segmenter::OutputParameters::m_rType, te::rp::Segmenter::SegmenterThreadEntryParams::m_runningThreadsCounterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_segmentsIdsManagerPtr, te::rp::SegmenterSegmentsBlock::m_segmentsMatrixXIndex, te::rp::SegmenterSegmentsBlock::m_segmentsMatrixYIndex, te::rp::Segmenter::SegmenterThreadEntryParams::m_segsBlocksMatrixPtr, te::rp::SegmenterSegmentsBlock::m_startX, te::rp::SegmenterSegmentsBlock::m_startY, te::rp::SegmenterSegmentsBlock::m_status, te::rp::Segmenter::InputParameters::m_strategyName, te::rp::Segmenter::SegmenterThreadEntryParams::m_threadErrorMessagePtr, te::rp::SegmenterSegmentsBlock::m_topCutOffProfile, te::rp::SegmenterSegmentsBlock::m_width, te::rst::RasterFactory::make(), te::common::AbstractFactory< te::rp::SegmenterStrategy, std::string, std::less< std::string > >::make(), MIN, nCols, te::common::RAccess, te::rp::Matrix< TemplateElementType >::RAMMemPol, te::rp::Matrix< TemplateElementType >::reset(), segmenterThreadEntry(), te::rst::Band::setValue(), TERP_DEBUG_TRUE_OR_THROW, TERP_INSTANCE_TRUE_OR_RETURN_FALSE, te::dt::UINT32_TYPE, updateBlockCutOffProfiles(), and te::common::WAccess.

Referenced by te::qt::widgets::SegmenterWizardPage::apply(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_SUITE(), te::qt::widgets::SegmenterDialog::on_okPushButton_clicked(), te::idl::rp::RegionGrowingSegmenter(), Segmenter(), and SegmentImage().

bool te::rp::Segmenter::genImageHCutOffProfile ( const unsigned int  profileCenter,
const te::rst::Raster inRaster,
const std::vector< unsigned int > &  inRasterBands,
const unsigned int  pixelNeighborhoodSize,
const unsigned int  tileNeighborhoodSize,
const unsigned int  profileAntiSmoothingFactor,
std::vector< unsigned int > &  profile 
) const
protected

Generate the horizontal cutOff prifles for the entire image..

Parameters
profileCenterThe profile center line.
inRasterThe input raster.
inRasterBandsThe input raster bands.
pixelNeighborhoodSizeThe pixel neighborhood size over the line transverse to each tile line.
tileNeighborhoodSizeThe buffer size around each tile.
profileAntiSmoothingFactorA positive profile anti-smoothing factor.
profileThe generated profile (each element is a inRaster line index ).
Returns
true if OK, false on errors.

Definition at line 1082 of file src/terralib/rp/Segmenter.cpp.

References ABS, te::rst::Raster::getNumberOfBands(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Raster::getValue(), MAX, MIN, and TERP_DEBUG_TRUE_OR_THROW.

Referenced by execute().

bool te::rp::Segmenter::genImageVCutOffProfile ( const unsigned int  profileCenter,
const te::rst::Raster inRaster,
const std::vector< unsigned int > &  inRasterBands,
const unsigned int  pixelNeighborhoodSize,
const unsigned int  tileNeighborhoodSize,
const unsigned int  profileAntiSmoothingFactor,
std::vector< unsigned int > &  profile 
) const
protected

Generate the vertical cutOff prifles for the entire image..

Parameters
profileCenterThe profile center column.
inRasterThe input raster.
inRasterBandsThe input raster bands.
pixelNeighborhoodSizeThe pixel neighborhood size over the line transverse to each tile line.
tileNeighborhoodSizeThe buffer size around each tile.
profileAntiSmoothingFactorA positive profile anti-smoothing factor.
profileThe generated profile (each element is a inRaster column index )
Returns
true if OK, false on errors.

Definition at line 1226 of file src/terralib/rp/Segmenter.cpp.

References ABS, te::rst::Raster::getNumberOfBands(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Raster::getValue(), MAX, MIN, and TERP_DEBUG_TRUE_OR_THROW.

Referenced by execute().

bool te::rp::Segmenter::isInitialized ( ) const
virtual

Returns true if the algorithm instance is initialized and ready for execution.

Returns
true if the algorithm instance is initialized and ready for execution.

Implements te::rp::Algorithm.

Definition at line 840 of file src/terralib/rp/Segmenter.cpp.

References m_instanceInitialized.

void te::rp::Segmenter::reset ( )
throw (te::rp::Exception
)
virtual

Clear all internal allocated objects and reset the algorithm to its initial state.

Reimplemented from te::rp::Algorithm.

Definition at line 793 of file src/terralib/rp/Segmenter.cpp.

References m_inputParameters, m_instanceInitialized, te::rp::Algorithm::reset(), and te::rp::Segmenter::InputParameters::reset().

void te::rp::Segmenter::segmenterThreadEntry ( SegmenterThreadEntryParams paramsPtr)
staticprotected

Segmenter thread entry.

Parameters
paramsPtrA pointer to the segmenter thread parameters.

Definition at line 893 of file src/terralib/rp/Segmenter.cpp.

References te::rp::SegmenterSegmentsBlock::BlockNotProcessed, te::rp::SegmenterSegmentsBlock::BlockSegmented, te::rp::SegmenterSegmentsBlock::BlockUnderSegmentation, te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rp::Segmenter::InputParameters::getSegStrategyParams(), te::rp::Segmenter::SegmenterThreadEntryParams::m_abortSegmentationFlagPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_blockProcessedSignalMutexPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_blockProcessedSignalPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_enableStrategyProgress, te::rp::Segmenter::SegmenterThreadEntryParams::m_generalMutexPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputParameters, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterBandMaxValues, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterBandMinValues, te::rp::Segmenter::InputParameters::m_inputRasterBands, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterNoDataValues, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterSyncPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_maxInputRasterCachedBlocks, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputParametersPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputRasterSyncPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_runningThreadsCounterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_segmentsIdsManagerPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_segsBlocksMatrixPtr, te::rp::SegmenterSegmentsBlock::m_status, te::rp::Segmenter::InputParameters::m_strategyName, te::rp::Segmenter::SegmenterThreadEntryParams::m_threadErrorMessagePtr, te::common::AbstractFactory< te::rp::SegmenterStrategy, std::string, std::less< std::string > >::make(), TERP_DEBUG_TRUE_OR_THROW, and TERP_TRUE_OR_THROW.

Referenced by execute().

void te::rp::Algorithm::setErrorMessage ( const std::string &  newErrorMessage)
protectedinherited

Set the current error message.

Parameters
newErrorMessageNew error message;

Definition at line 49 of file rp/Algorithm.cpp.

References te::rp::Algorithm::m_errorMessage.

bool te::rp::Segmenter::updateBlockCutOffProfiles ( const std::vector< std::vector< unsigned int > > &  imageHorizontalProfiles,
const std::vector< std::vector< unsigned int > > &  imageVerticalProfiles,
SegmenterSegmentsBlock segmentsBlock 
) const
protected

Update the block cutOff profiles using the full image profiles.

Parameters
imageVerticalProfilesThe generated horizontal profiles (empty profiles also will be accepted).
horizontalProfilesThe generated vertical profiles (empty profiles also will be accepted).
segmentsBlockThe block to update.
Returns
true if OK, false on errors.

Definition at line 1370 of file src/terralib/rp/Segmenter.cpp.

References te::rp::SegmenterSegmentsBlock::m_bottomCutOffProfile, te::rp::SegmenterSegmentsBlock::m_height, te::rp::SegmenterSegmentsBlock::m_leftCutOffProfile, te::rp::SegmenterSegmentsBlock::m_rightCutOffProfile, te::rp::SegmenterSegmentsBlock::m_segmentsMatrixXIndex, te::rp::SegmenterSegmentsBlock::m_segmentsMatrixYIndex, te::rp::SegmenterSegmentsBlock::m_startX, te::rp::SegmenterSegmentsBlock::m_startY, te::rp::SegmenterSegmentsBlock::m_topCutOffProfile, te::rp::SegmenterSegmentsBlock::m_width, MAX, and MIN.

Referenced by execute().

Member Data Documentation

bool te::rp::Segmenter::m_instanceInitialized
protected

Definition at line 258 of file src/terralib/rp/Segmenter.h.

Referenced by execute(), initialize(), isInitialized(), reset(), and Segmenter().


The documentation for this class was generated from the following files: