29 #include "../../../rp/Segmenter.h"
30 #include "../../../rp/SegmenterRegionGrowingStrategy.h"
31 #include <ui_SegmenterForm.h>
33 #include <QMessageBox>
34 #include <QListWidgetItem>
39 te::rst::Raster const* inputRasterPtr,
const std::string& outpuRasterDSType,
40 const std::map< std::string, std::string >& outpuRasterInfo,
41 QWidget* parent, Qt::WindowFlags f)
42 : QDialog( parent, f ),
43 m_inputRasterPtr( inputRasterPtr ),
44 m_outpuRasterDSType( outpuRasterDSType ),
45 m_outpuRasterInfo( outpuRasterInfo )
47 m_uiPtr =
new Ui::SegmenterForm;
55 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
58 m_uiPtr->m_inputRasterBandsListWidget->addItem(
59 QString::number( inRasterBandsIdx ) );
69 boost::shared_ptr< te::rst::Raster >& outputRasterPtr )
71 if( m_outputRasterPtr.get() )
73 outputRasterPtr = m_outputRasterPtr;
84 m_outputRasterPtr.reset();
86 if( m_inputRasterPtr )
94 QList<QListWidgetItem *> selectedBands =
95 m_uiPtr->m_inputRasterBandsListWidget->selectedItems();
97 if( selectedBands.size() > 0 )
99 QList<QListWidgetItem *>::const_iterator itBegin = selectedBands.begin();
100 QList<QListWidgetItem *>::const_iterator itEnd = selectedBands.end();
101 while( itBegin != itEnd )
108 m_uiPtr->m_enableThreadedProcessingcheckBox->isChecked();
109 algoInputParams.
m_maxSegThreads = m_uiPtr->m_maximumThreadsNumberLineEdit->text().toUInt();
111 m_uiPtr->m_enableBlockProcessingcheckBox->isChecked();
114 algoInputParams.
m_maxBlockSize = m_uiPtr->m_maximumBlockSizeLineEdit->text().toUInt();
117 algoInputParams.
m_strategyName = m_uiPtr->m_segmenterStrategyComboBox->currentText().toStdString();
123 m_uiPtr->m_minimumSegmentSizeRGLineEdit->text().toUInt();
125 m_uiPtr->m_segmentsSimilarityThresholdRGLineEdit->text().toDouble();
130 algoOutputParams.
m_rInfo = m_outpuRasterInfo;
131 algoOutputParams.
m_rType = m_outpuRasterDSType;
137 if( algorithmInstance.
initialize( algoInputParams ) )
139 if( algorithmInstance.
execute( algoOutputParams ) )
142 QMessageBox::information(
this,
"", tr(
"Segmentation ended sucessfully"));
146 QMessageBox::critical(
this,
"", tr(
"Segmentation execution error"));
151 QMessageBox::critical(
this,
"", tr(
"Segmentation initialization error"));
156 QMessageBox::critical(
this,
"", tr(
"Invalid number of bands"));
161 QMessageBox::critical(
this,
"", tr(
"Invalid input raster"));
Segmenter Output Parameters.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
A pointer the ge generated output raster (label image).
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
A dialog used to execute image segmentation.
An abstract class for raster data strucutures.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
unsigned int m_minSegmentSize
A positive minimum segment size (pixels number - default: 100).
double m_segmentsSimilarityThreshold
Segments similarity treshold - Use lower values to merge only those segments that are more similar - ...
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.