29 #include "../../../rp/Contrast.h"
30 #include <ui_ContrastForm.h>
32 #include <QMessageBox>
33 #include <QListWidgetItem>
38 te::rst::Raster const* inputRasterPtr,
const std::string& outpuRasterDSType,
39 const std::map< std::string, std::string >& outpuRasterInfo,
40 QWidget* parent, Qt::WindowFlags f)
41 : QDialog( parent, f ),
42 m_inputRasterPtr( inputRasterPtr ),
43 m_outputRasterIsInputRaster( false ),
44 m_outpuRasterDSType( outpuRasterDSType ),
45 m_outpuRasterInfo( outpuRasterInfo )
55 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
58 m_uiPtr->m_inputRasterBandsListWidget->addItem(
59 QString::number( inRasterBandsIdx ) );
64 te::rst::Raster const* inputRasterPtr, QWidget* parent, Qt::WindowFlags f)
65 : QDialog( parent, f ),
66 m_inputRasterPtr( inputRasterPtr ),
67 m_outputRasterIsInputRaster( true )
77 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
80 m_uiPtr->m_inputRasterBandsListWidget->addItem(
81 QString::number( inRasterBandsIdx ) );
91 boost::shared_ptr< te::rst::Raster >& outputRasterPtr )
93 if( m_outputRasterPtr.get() )
95 outputRasterPtr = m_outputRasterPtr;
106 m_outputRasterPtr.reset();
108 if( m_inputRasterPtr )
117 QList<QListWidgetItem *> selectedBands =
118 m_uiPtr->m_inputRasterBandsListWidget->selectedItems();
120 if( selectedBands.size() > 0 )
122 QList<QListWidgetItem *>::const_iterator itBegin = selectedBands.begin();
123 QList<QListWidgetItem *>::const_iterator itEnd = selectedBands.end();
124 while( itBegin != itEnd )
126 algoInputParams.
m_inRasterBands.push_back( (*itBegin)->text().toUInt() );
131 if( m_uiPtr->m_contrastTypeComboBox->currentText() ==
132 tr(
"Histogram Equalization" ) )
137 m_uiPtr->m_hECMaxInputLineEdit->text().toDouble() );
139 else if( m_uiPtr->m_contrastTypeComboBox->currentText() ==
144 algoInputParams.
m_lCMinInput.resize( selectedBands.size(),
145 m_uiPtr->m_lCMinInputLineEdit->text().toDouble() );
146 algoInputParams.
m_lCMaxInput.resize( selectedBands.size(),
147 m_uiPtr->m_lCMaxInputLineEdit->text().toDouble() );
149 else if( m_uiPtr->m_contrastTypeComboBox->currentText() ==
150 tr(
"Mean and standard deviation" ) )
155 m_uiPtr->m_sMASCMeanInputLineEdit->text().toDouble() );
157 m_uiPtr->m_sMASCStdInputLineEdit->text().toDouble() );
160 if( m_outputRasterIsInputRaster )
174 if( algorithmInstance.
initialize( algoInputParams ) )
176 if( algorithmInstance.
execute( algoOutputParams ) )
178 if( ! m_outputRasterIsInputRaster )
183 QMessageBox::information(
this,
"", tr(
"Contrast enhencement ended sucessfully"));
187 QMessageBox::critical(
this,
"", tr(
"Contrast enhencement execution error"));
192 QMessageBox::critical(
this,
"", tr(
"Contrast enhencement initialization error"));
197 QMessageBox::critical(
this,
"", tr(
"Invalid number of bands"));
202 QMessageBox::critical(
this,
"", tr(
"Invalid input raster"));
te::rst::Raster * m_outRasterPtr
A pointer to a valid initiated raster instance where the result must be written, leave NULL to create...
An abstract class for raster data strucutures.
std::vector< unsigned int > m_outRasterBands
Bands to be processed from the output raster.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::auto_ptr< te::rst::Raster > m_createdOutRasterPtr
A pointer to the created output raster instance, or an empty pointer empty if the result must be writ...
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
std::string m_createdOutRasterDSType
Output raster data source type (as described in te::raster::RasterFactory ), leave empty if the resul...
A dialog used to execute image contrast enhencement.
Contrast output parameters.
std::map< std::string, std::string > m_createdOutRasterInfo
The necessary information to create the raster (as described in te::raster::RasterFactory), leave empty if the result must be written to the raster pointed m_outRasterPtr.