All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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...
 
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
< SegmenterSegmentsBlock
SegmentsBlocksMatrixT
 

Protected Member Functions

bool calcBestBlockSize (const unsigned int totalImageLines, const unsigned int totalImageCols, const unsigned int minExapandedBlockPixels, const unsigned int maxExapandedBlockPixels, const unsigned int blocksHOverlapSize, const unsigned int blocksVOverlapSize, unsigned int &nonExpandedBlockWidth, unsigned int &nonExpandedBlockHeight) 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...
 
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 72 of file Segmenter.h.

Member Typedef Documentation

Segments blocks matrix type definition

Definition at line 191 of file Segmenter.h.

Constructor & Destructor Documentation

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

Definition at line 201 of file Segmenter.cpp.

References m_instanceInitialized.

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

Definition at line 206 of file Segmenter.cpp.

Member Function Documentation

bool te::rp::Segmenter::calcBestBlockSize ( const unsigned int  totalImageLines,
const unsigned int  totalImageCols,
const unsigned int  minExapandedBlockPixels,
const unsigned int  maxExapandedBlockPixels,
const unsigned int  blocksHOverlapSize,
const unsigned int  blocksVOverlapSize,
unsigned int &  nonExpandedBlockWidth,
unsigned int &  nonExpandedBlockHeight 
) const
protected

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

Parameters
totalImageLinesThe total original full image lines.
totalImageColsThe total original full image columns.
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).
blockWidthThe calculated block width (non-expanded block).
blockHeightThe calculated block height (non-expanded block).
Returns
true if OK, false on errors.

Definition at line 765 of file Segmenter.cpp.

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.

Implements te::rp::Algorithm.

Definition at line 210 of file Segmenter.cpp.

References te::rp::SegmenterSegmentsBlock::BlockNotProcessed, te::rp::SegmenterSegmentsBlock::BlockSegmented, calcBestBlockSize(), genImageHCutOffProfile(), genImageVCutOffProfile(), te::rst::Raster::getBand(), te::rst::Raster::getBandDataType(), 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::GetPixelSize(), te::rst::Band::getProperty(), te::rp::Segmenter::InputParameters::getSegStrategyParams(), te::common::GetTotalPhysicalMemory(), te::common::GetTotalVirtualMemory(), te::common::GetUsedVirtualMemory(), te::rst::Band::getValue(), 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_enableBlockMerging, 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, m_inputParameters, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputParametersPtr, te::rp::Segmenter::InputParameters::m_inputRasterBands, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterGainsPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterIOMutexPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterOffsetsPtr, te::rp::Segmenter::InputParameters::m_inputRasterPtr, m_instanceInitialized, te::rp::Segmenter::InputParameters::m_maxBlockSize, te::rp::Segmenter::InputParameters::m_maxSegThreads, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputParametersPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputRasterIOMutexPtr, te::rp::Segmenter::OutputParameters::m_outputRasterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_progressPtr, 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::SegmenterSegmentsBlock::m_width, te::rst::RasterFactory::make(), te::common::AbstractFactory< te::rp::SegmenterStrategy, std::string, std::less< std::string > >::make(), MAX, MIN, te::rp::Matrix< TemplateElementType >::RAMMemPol, te::rp::Matrix< TemplateElementType >::reset(), segmenterThreadEntry(), TERP_DEBUG_TRUE_OR_THROW, TERP_TRUE_OR_RETURN_FALSE, te::dt::UINT32_TYPE, and updateBlockCutOffProfiles().

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

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 1261 of file 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 1397 of file 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::initialize ( const AlgorithmInputParameters inputParams)
throw (te::rp::Exception
)
virtual
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 760 of file Segmenter.cpp.

References m_instanceInitialized.

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

Segmenter thread entry.

Parameters
paramsPtrA pointer to the segmenter thread parameters.

Definition at line 802 of file Segmenter.cpp.

References te::rp::SegmenterSegmentsBlock::BlockNotProcessed, te::rp::SegmenterSegmentsBlock::BlockSegmented, te::rp::SegmenterSegmentsBlock::BlockUnderSegmentation, te::rst::Raster::getBand(), te::rp::Matrix< TemplateElementType >::getColumnsNumber(), te::rst::Raster::getGrid(), te::rp::Matrix< TemplateElementType >::getLinesNumber(), te::rst::Raster::getNumberOfColumns(), te::rst::Raster::getNumberOfRows(), te::rst::Grid::getResolutionX(), te::rst::Grid::getResolutionY(), te::rp::Segmenter::InputParameters::getSegStrategyParams(), te::rst::Grid::getSRID(), te::rst::Band::getValue(), te::rst::GrayIdxCInt, te::rst::Grid::gridToGeo(), te::common::TaskProgress::isActive(), te::rp::Segmenter::SegmenterThreadEntryParams::m_abortSegmentationFlagPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_blockProcessedSignalMutexPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_blockProcessedSignalPtr, te::rp::SegmenterSegmentsBlock::m_bottomCutOffProfile, te::rst::BandProperty::m_colorInterp, te::rp::Segmenter::InputParameters::m_enableBlockMerging, te::rp::Segmenter::InputParameters::m_enableBlockProcessing, te::rp::Segmenter::SegmenterThreadEntryParams::m_enableStrategyProgress, te::rp::Segmenter::SegmenterThreadEntryParams::m_generalMutexPtr, te::rp::SegmenterSegmentsBlock::m_height, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputParametersPtr, te::rp::Segmenter::InputParameters::m_inputRasterBands, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterGainsPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterIOMutexPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_inputRasterOffsetsPtr, te::rp::Segmenter::InputParameters::m_inputRasterPtr, te::rp::SegmenterSegmentsBlock::m_leftCutOffProfile, te::rst::BandProperty::m_noDataValue, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputParametersPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_outputRasterIOMutexPtr, te::rp::Segmenter::OutputParameters::m_outputRasterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_progressPtr, te::rp::SegmenterSegmentsBlock::m_rightCutOffProfile, te::rp::Segmenter::SegmenterThreadEntryParams::m_runningThreadsCounterPtr, te::rp::Segmenter::SegmenterThreadEntryParams::m_segmentsIdsManagerPtr, 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::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(), te::common::TaskProgress::pulse(), te::rst::Band::setValue(), TERP_DEBUG_TRUE_OR_THROW, TERP_TRUE_OR_THROW, and te::dt::UINT32_TYPE.

Referenced by execute().

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 1533 of file 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, MIN, and TERP_DEBUG_TRUE_OR_THROW.

Referenced by execute().

Member Data Documentation

Segmenter::InputParameters te::rp::Segmenter::m_inputParameters
protected

Segmenter execution parameters.

Definition at line 251 of file Segmenter.h.

Referenced by createCutOffLinesTiff(), execute(), initialize(), and reset().

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

Definition at line 249 of file Segmenter.h.

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


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