ISOSeg strategy for OBIA classification. The algorithm orders regions by area (larger first), and classify the largest region as Cluster 1. All regions similar to this cluster are inserted in Cluster 1, otherwise new Clusters are created. After all regions belong to a cluster, the algorithm merges similar clusters. The acceptance threshold is the only parameter given by the user, and it indicates the maximum distance between two regions to be clustered togheter. More...
#include <ClassifierISOSegStrategy.h>
Classes | |
| class | FillRegionsThreadEntryParams |
| The parameters passed to the fill regions thread entry. More... | |
| class | Parameters |
| Classifier Parameters. More... | |
| class | Pattern |
| Describes a region or a cluster (group of regions with similar properties) to be used by ISOSeg method. More... | |
Public Member Functions | |
| ClassifierISOSegStrategy () | |
| void | enableMultiThread (const bool &enable) |
| Enable / disable the use of multiple threads. More... | |
| void | enableOutputPalette (const bool enabled) |
| Enable (true) or disable (false) the creation of a paletted output raster. More... | |
| void | enableProgressInterface (const bool &enable) |
| Enable / disable the progress interface. More... | |
| void | enableRasterCache (const bool &enable) |
| Enable / disable the use of raster data cache. More... | |
| bool | execute () throw (te::rp::Exception) |
| Executes the classification strategy. More... | |
| const std::string & | getErrorMessage () const |
| Return the current error message if there is any. More... | |
| void | getMetaData (std::map< std::string, std::string > &metadata) const |
| Returns strategy-dependent metadata. More... | |
| bool | initialize (ClassifierStrategyParameters const *const strategyParams) throw (te::rp::Exception) |
| Initialize the classification strategy. More... | |
| std::unique_ptr< te::rst::Raster > | releaseOutputRaster () |
| Returns a pointer to the output raster or a void pointer if there is none. More... | |
| void | setInputPolygons (const std::vector< te::gm::Polygon * > &polygonsPtrs) |
| Set the input polygons. More... | |
| void | setInputRaster (const te::rst::Raster &raster) |
| Set the input raster. More... | |
| void | setInputRasterBands (const std::vector< unsigned int > &rasterBands) |
| Set the input raste bandsr. More... | |
| void | setUserOutputPalette (std::vector< te::rst::BandProperty::ColorEntry > &userPalette) |
| Set the output user palette. More... | |
| ~ClassifierISOSegStrategy () | |
Protected Member Functions | |
| bool | createOutputRaster (const std::vector< int > &bandsDataTypes, const std::vector< double > &noDataValues) |
| Create the output raster using the EXPANSIBLE driver. More... | |
| double | getThreshold (const double acceptanceThreshold, const unsigned nBands) const |
| virtual void | reset () |
| Reset to an initial state. More... | |
| void | setErrorMessage (const std::string &newErrorMessage) |
| Set the current error message. More... | |
| bool | setOutputRasterPalette (const unsigned int size) |
| Create and set the output raster palette folowing the current internal settings. More... | |
Static Protected Member Functions | |
| static void | fillRegionsThreadEntry (FillRegionsThreadEntryParams *paramsPtr) |
| Fill regions thread entry. More... | |
| static void | printMatrix (const boost::numeric::ublas::matrix< double > &matrix) |
| Print a matrix to std::out. More... | |
Protected Attributes | |
| bool | m_createRasterPalette |
| Enable (true) or disable (false) the creation of a paletted output raster. More... | |
| bool | m_enableMultiThread |
| Enable or disable the use multipe threads. More... | |
| bool | m_enableRasterCache |
| Enable or disable the use a raster data cache. More... | |
| std::vector< te::gm::Polygon * > const * | m_inputPolygonsPtr |
| Input polygons. More... | |
| std::vector< unsigned int > | m_inputRasterBands |
| Input raster bands. More... | |
| te::rst::Raster const * | m_inputRasterPtr |
| A pointer to the input raster. More... | |
| bool | m_isInitialized |
| True if this instance is initialized. More... | |
| std::map< std::string, std::string > | m_metaData |
| Strategy-dependent metadata. More... | |
| std::unique_ptr< te::rst::Raster > | m_outputRasterPtr |
| A pointer to the output raster. More... | |
| ClassifierISOSegStrategy::Parameters | m_parameters |
| Internal execution parameters. More... | |
| bool | m_progressInterfaceEnabled |
| Progress interface status. More... | |
| std::vector< te::rst::BandProperty::ColorEntry > | m_userOutputPalette |
| User output raster palette (it must be large enough to accomodate all classifyier generated classes or an empty vector to automatically generate an random palette. More... | |
ISOSeg strategy for OBIA classification. The algorithm orders regions by area (larger first), and classify the largest region as Cluster 1. All regions similar to this cluster are inserted in Cluster 1, otherwise new Clusters are created. After all regions belong to a cluster, the algorithm merges similar clusters. The acceptance threshold is the only parameter given by the user, and it indicates the maximum distance between two regions to be clustered togheter.
Definition at line 58 of file ClassifierISOSegStrategy.h.
| te::rp::ClassifierISOSegStrategy::ClassifierISOSegStrategy | ( | ) |
Definition at line 274 of file ClassifierISOSegStrategy.cpp.
References m_isInitialized, and ~ClassifierISOSegStrategy().
|
default |
Referenced by ClassifierISOSegStrategy().
|
protectedinherited |
Create the output raster using the EXPANSIBLE driver.
| bandsDataTypes | Bands data types. |
| noDataValues | A vector of no-data values for each band. |
Definition at line 105 of file ClassifierStrategy.cpp.
References te::rst::Raster::getBand(), te::rst::Raster::getGrid(), te::rst::Band::getProperty(), te::rst::GrayIdxCInt, te::sa::Grid, te::rst::BandProperty::m_colorInterp, te::rp::ClassifierStrategy::m_inputRasterBands, te::rp::ClassifierStrategy::m_inputRasterPtr, te::rst::BandProperty::m_noDataValue, te::rp::ClassifierStrategy::m_outputRasterPtr, te::rst::BandProperty::m_type, te::rst::RasterFactory::make(), and TERP_TRUE_OR_THROW.
Referenced by te::rp::ClassifierDummyStrategy::execute(), te::rp::ClassifierKMeansStrategy::execute(), te::rp::ClassifierEDStrategy::execute(), te::rp::ClassifierEMStrategy::execute(), te::rp::ClassifierMAPStrategy::execute(), te::rp::ClassifierSAMStrategy::execute(), and execute().
|
inherited |
Enable / disable the use of multiple threads.
| enable | Enable (true) or disable (false) the use of multiple threads. |
Definition at line 80 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_enableMultiThread.
|
inherited |
Enable (true) or disable (false) the creation of a paletted output raster.
| enabled | Enable (true) or disable (false) the creation of a paletted output raster. |
Definition at line 90 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_createRasterPalette.
|
inherited |
Enable / disable the progress interface.
| enable | Enable (true) or disable (false) the progress interface. |
Definition at line 70 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_progressInterfaceEnabled.
|
inherited |
Enable / disable the use of raster data cache.
| enable | Enable (true) or disable (false) the use of raster cache. |
Definition at line 75 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_enableRasterCache.
|
virtual | |||||||||||||
Executes the classification strategy.
< A descriptive set of regions (area, features).
Implements te::rp::ClassifierStrategy.
Definition at line 320 of file ClassifierISOSegStrategy.cpp.
References te::rst::PolygonIterator< T >::begin(), te::rp::ClassifierISOSegStrategy::Parameters::BhattacharyyaDistanceType, col, te::rp::ClassifierStrategy::createOutputRaster(), dt, te::rst::PolygonIterator< T >::end(), fillRegionsThreadEntry(), te::rst::PolygonIterator< T >::getColumn(), te::common::GetPhysProcNumber(), te::rst::PolygonIterator< T >::getRow(), getThreshold(), te::rp::ClassifierISOSegStrategy::Parameters::m_acceptanceThreshold, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_condVarMutexPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_condVarPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_continueProcessingFlagPtr, te::rp::ClassifierISOSegStrategy::Parameters::m_distanceType, te::rp::ClassifierStrategy::m_enableMultiThread, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_enableProgress, te::rp::ClassifierStrategy::m_enableRasterCache, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_globalMutexPtr, te::rp::ClassifierStrategy::m_inputPolygonsPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_inputPolygonsPtr, te::rp::ClassifierStrategy::m_inputRasterBands, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_inputRasterBandsPtr, te::rp::ClassifierStrategy::m_inputRasterPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_inputRasterSyncPtr, m_isInitialized, te::rp::ClassifierISOSegStrategy::Pattern::m_myCluster, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_nextInputPolIdx2ProcessPtr, te::rp::ClassifierStrategy::m_outputRasterPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_outputRegionsPtr, m_parameters, te::rp::ClassifierStrategy::m_progressInterfaceEnabled, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_runningThreadsCounterPtr, te::rp::ClassifierISOSegStrategy::Parameters::MahalanobisDistanceType, nCols, te::common::RAccess, te::rp::ClassifierISOSegStrategy::Pattern::reset(), te::rp::ClassifierStrategy::setOutputRasterPalette(), te::rst::Band::setValue(), TE_TR, TERP_INSTANCE_TRUE_OR_RETURN_FALSE, TERP_LOG_AND_THROW, te::dt::UINT32_TYPE, and te::common::TaskProgress::UNDEFINED.
|
staticprotected |
Fill regions thread entry.
| paramsPtr | A pointer to the thread parameters. |
Definition at line 719 of file ClassifierISOSegStrategy.cpp.
References te::rst::PolygonIterator< T >::begin(), te::rst::PolygonIterator< T >::end(), te::rst::SynchronizedRaster::getBand(), te::rst::PolygonIterator< T >::getColumn(), te::common::GetDeterminant(), te::common::GetInverseMatrix(), te::rst::Band::getProperty(), te::rst::PolygonIterator< T >::getRow(), te::rst::Raster::getValue(), te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_continueProcessingFlagPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_enableProgress, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_globalMutexPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_inputPolygonsPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_inputRasterBandsPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_inputRasterSyncPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_nextInputPolIdx2ProcessPtr, te::rst::BandProperty::m_noDataValue, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_outputRegionsPtr, te::rp::ClassifierISOSegStrategy::FillRegionsThreadEntryParams::m_runningThreadsCounterPtr, TE_TR, and te::common::TaskProgress::UNDEFINED.
Referenced by execute().
|
inherited |
Return the current error message if there is any.
Definition at line 100 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_errorMessage.
|
inherited |
Returns strategy-dependent metadata.
| metadata | Strategy-dependent metadata. |
Definition at line 85 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_metaData.
|
protected |
Definition at line 304 of file ClassifierISOSegStrategy.cpp.
References classifierISOSegStrategyChiTable.
Referenced by execute().
|
virtual | ||||||||||||||
Initialize the classification strategy.
| strategyParams | A pointer to the user given specific classification strategy parameters ou NULL if no parameters are present. |
Implements te::rp::ClassifierStrategy.
Definition at line 281 of file ClassifierISOSegStrategy.cpp.
References te::rp::ClassifierISOSegStrategy::Parameters::BhattacharyyaDistanceType, te::rp::ClassifierISOSegStrategy::Parameters::m_acceptanceThreshold, te::rp::ClassifierISOSegStrategy::Parameters::m_distanceType, m_isInitialized, m_parameters, te::rp::ClassifierISOSegStrategy::Parameters::MahalanobisDistanceType, and TERP_INSTANCE_TRUE_OR_RETURN_FALSE.
|
staticprotected |
Print a matrix to std::out.
Definition at line 962 of file ClassifierISOSegStrategy.cpp.
|
inherited |
Returns a pointer to the output raster or a void pointer if there is none.
Definition at line 60 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_outputRasterPtr.
|
protectedvirtualinherited |
Reset to an initial state.
Definition at line 185 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_createRasterPalette, te::rp::ClassifierStrategy::m_enableMultiThread, te::rp::ClassifierStrategy::m_enableRasterCache, te::rp::ClassifierStrategy::m_errorMessage, te::rp::ClassifierStrategy::m_inputPolygonsPtr, te::rp::ClassifierStrategy::m_inputRasterBands, te::rp::ClassifierStrategy::m_inputRasterPtr, te::rp::ClassifierStrategy::m_metaData, te::rp::ClassifierStrategy::m_outputRasterPtr, te::rp::ClassifierStrategy::m_progressInterfaceEnabled, and te::rp::ClassifierStrategy::m_userOutputPalette.
Referenced by te::rp::ClassifierStrategy::ClassifierStrategy(), and te::rp::ClassifierStrategy::operator=().
|
protectedinherited |
Set the current error message.
| newErrorMessage | New error message; |
Definition at line 180 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_errorMessage.
|
inherited |
Set the input polygons.
| polygonsPtrs | Input polygons pointers. |
Definition at line 65 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_inputPolygonsPtr.
|
inherited |
Set the input raster.
| raster | Input raster. |
Definition at line 50 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_inputRasterPtr.
|
inherited |
Set the input raste bandsr.
| rasterBands | Input raster bands. |
Definition at line 55 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_inputRasterBands.
|
protectedinherited |
Create and set the output raster palette folowing the current internal settings.
| size | Palette size. |
Definition at line 145 of file ClassifierStrategy.cpp.
References te::rp::CreateFixedStepPalette(), te::rp::ClassifierStrategy::m_createRasterPalette, te::rp::ClassifierStrategy::m_outputRasterPtr, te::rp::ClassifierStrategy::m_userOutputPalette, te::rst::PaletteIdxCInt, and te::rst::RGBPalInt.
Referenced by te::rp::ClassifierDummyStrategy::execute(), te::rp::ClassifierKMeansStrategy::execute(), te::rp::ClassifierEDStrategy::execute(), te::rp::ClassifierEMStrategy::execute(), te::rp::ClassifierMAPStrategy::execute(), te::rp::ClassifierSAMStrategy::execute(), and execute().
|
inherited |
Set the output user palette.
| userPalette | User output raster palette (it must be large enough to accomodate all classifyier generated classes or an empty vector to automatically generate an random palette. |
Definition at line 95 of file ClassifierStrategy.cpp.
References te::rp::ClassifierStrategy::m_userOutputPalette.
|
protectedinherited |
Enable (true) or disable (false) the creation of a paletted output raster.
Definition at line 164 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::enableOutputPalette(), te::rp::ClassifierStrategy::reset(), and te::rp::ClassifierStrategy::setOutputRasterPalette().
|
protectedinherited |
Enable or disable the use multipe threads.
Definition at line 159 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::enableMultiThread(), execute(), and te::rp::ClassifierStrategy::reset().
|
protectedinherited |
Enable or disable the use a raster data cache.
Definition at line 154 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::enableRasterCache(), execute(), and te::rp::ClassifierStrategy::reset().
|
protectedinherited |
Input polygons.
Definition at line 179 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierDummyStrategy::execute(), execute(), te::rp::ClassifierStrategy::reset(), and te::rp::ClassifierStrategy::setInputPolygons().
|
protectedinherited |
Input raster bands.
Definition at line 174 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::createOutputRaster(), te::rp::ClassifierKMeansStrategy::execute(), te::rp::ClassifierEDStrategy::execute(), te::rp::ClassifierEMStrategy::execute(), te::rp::ClassifierMAPStrategy::execute(), te::rp::ClassifierSAMStrategy::execute(), execute(), te::rp::ClassifierStrategy::reset(), and te::rp::ClassifierStrategy::setInputRasterBands().
|
protectedinherited |
A pointer to the input raster.
Definition at line 144 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::createOutputRaster(), te::rp::ClassifierKMeansStrategy::execute(), te::rp::ClassifierEDStrategy::execute(), te::rp::ClassifierEMStrategy::execute(), te::rp::ClassifierMAPStrategy::execute(), te::rp::ClassifierSAMStrategy::execute(), execute(), te::rp::ClassifierStrategy::reset(), and te::rp::ClassifierStrategy::setInputRaster().
|
protected |
True if this instance is initialized.
Definition at line 228 of file ClassifierISOSegStrategy.h.
Referenced by ClassifierISOSegStrategy(), execute(), and initialize().
|
protectedinherited |
Strategy-dependent metadata.
Definition at line 184 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::getMetaData(), and te::rp::ClassifierStrategy::reset().
|
protectedinherited |
A pointer to the output raster.
Definition at line 169 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::createOutputRaster(), te::rp::ClassifierDummyStrategy::execute(), te::rp::ClassifierKMeansStrategy::execute(), te::rp::ClassifierEDStrategy::execute(), te::rp::ClassifierEMStrategy::execute(), te::rp::ClassifierMAPStrategy::execute(), te::rp::ClassifierSAMStrategy::execute(), execute(), te::rp::ClassifierStrategy::releaseOutputRaster(), te::rp::ClassifierStrategy::reset(), and te::rp::ClassifierStrategy::setOutputRasterPalette().
|
protected |
Internal execution parameters.
Definition at line 229 of file ClassifierISOSegStrategy.h.
Referenced by execute(), and initialize().
|
protectedinherited |
Progress interface status.
Definition at line 149 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::enableProgressInterface(), te::rp::ClassifierEDStrategy::execute(), te::rp::ClassifierMAPStrategy::execute(), te::rp::ClassifierSAMStrategy::execute(), execute(), and te::rp::ClassifierStrategy::reset().
|
protectedinherited |
User output raster palette (it must be large enough to accomodate all classifyier generated classes or an empty vector to automatically generate an random palette.
Definition at line 189 of file ClassifierStrategy.h.
Referenced by te::rp::ClassifierStrategy::reset(), te::rp::ClassifierStrategy::setOutputRasterPalette(), and te::rp::ClassifierStrategy::setUserOutputPalette().