27 #include "../../../common/StringUtils.h" 
   28 #include "../../../dataaccess/dataset/DataSet.h" 
   29 #include "../../../dataaccess/utils/Utils.h" 
   30 #include "../../../raster/Interpolator.h" 
   31 #include "../../../raster/Raster.h" 
   32 #include "../../../rp/Functions.h" 
   33 #include "../../../rp/SpectralResponseFunctions.h" 
   34 #include "../../../se/Utils.h" 
   36 #include "ui_FusionWizardPageForm.h" 
   39 #include <QApplication> 
   40 #include <QFileDialog> 
   41 #include <QGridLayout> 
   42 #include <QMessageBox> 
   51 #include <qwt_legend.h> 
   57   : QWizardPage(parent),
 
   58     m_ui(new Ui::FusionWizardPageForm),
 
   73   m_chartDialog = 
new QDialog(
this, Qt::Tool | Qt::WindowTitleHint);
 
   78   m_chartDisplay->setAxisTitle(QwtPlot::xBottom, tr(
"Wavelength in Microns"));
 
   80   m_chartDisplay->insertLegend(
new QwtLegend(), QwtPlot::RightLegend);
 
   83   connect(
m_ui->m_scatterBoolButton, SIGNAL(toggled(
bool)), 
m_chartDialog, SLOT(setVisible(
bool)));
 
   89   this->setTitle(tr(
"Fusion"));
 
   90   this->setSubTitle(tr(
"Select the type of fusion and set their specific parameters."));
 
   92   m_ui->m_scatterBoolButton->setIcon(QIcon::fromTheme(
"chart-lines"));
 
  107   m_layerLower = layer;
 
  109   m_ui->m_ihsLowerLineEdit->setText(m_layerLower->getTitle().c_str());
 
  110   m_ui->m_pcaLowerLineEdit->setText(m_layerLower->getTitle().c_str());
 
  111   m_ui->m_wisperLowerLineEdit->setText(m_layerLower->getTitle().c_str());
 
  118   m_layerHigher = layer;
 
  120   m_ui->m_higherLineEdit_IHS->setText(m_layerHigher->getTitle().c_str());
 
  121   m_ui->m_higherLineEdit_PCA->setText(m_layerHigher->getTitle().c_str());
 
  122   m_ui->m_higherLineEdit_Wisper->setText(m_layerHigher->getTitle().c_str());
 
  129   int idx = m_ui->m_fusionTypeComboBox->currentIndex();
 
  131   int type = m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
 
  141   int idx = m_ui->m_fusionTypeComboBox->currentIndex();
 
  143   int type = m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
 
  153   int idx = m_ui->m_fusionTypeComboBox->currentIndex();
 
  155   int type = m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
 
  165   return m_ui->m_cropCheckBox->isChecked();
 
  170   int interpolationIdx = m_ui->m_interpolatorComboBox->currentIndex();
 
  184   return algoInputParams;
 
  191   return algoOutputParams;
 
  196   int interpolationIdx = m_ui->m_interpolatorComboBox->currentIndex();
 
  204   int nBands = m_ui->m_listWidget->count();
 
  205   for(
int i = 0; i < nBands; ++i)
 
  207     if(m_ui->m_listWidget->item(i)->isSelected())
 
  213   return algoInputParams;
 
  220   return algoOutputParams;
 
  225   int idx = m_ui->m_interpolatorComboBox->currentIndex();
 
  233   int nBands = m_ui->m_wisperTableWidget->rowCount();
 
  234   for(
int i = 0; i < nBands; ++i)
 
  236     QTableWidgetItem* item =  m_ui->m_wisperTableWidget->item(i, 0);
 
  238     if(item->checkState() == Qt::Checked)
 
  242       QComboBox* cmbBox = (QComboBox*)m_ui->m_wisperTableWidget->cellWidget(i, 2);
 
  244       idx = cmbBox->currentIndex();
 
  246       std::string stName = cmbBox->itemText(idx).toStdString();
 
  255   idx = m_ui->m_sensorTypeComboBox->currentIndex();
 
  257   std::string stName = m_ui->m_sensorTypeComboBox->itemText(idx).toStdString();
 
  263   idx = m_ui->m_waveletComboBox->currentIndex();
 
  267   return algoInputParams;
 
  274   return algoOutputParams;
 
  280   if(!m_scatterHighRes)
 
  284     m_scatterChartHighRes->setPen(Qt::blue);
 
  285     m_scatterChartHighRes->setSymbol(0);
 
  286     m_scatterChartHighRes->setStyle(QwtPlotCurve::Lines);
 
  287     m_scatterChartHighRes->attach(m_chartDisplay);
 
  288     m_scatterChartHighRes->setTitle(tr(
"High Resolution"));
 
  292   std::string stName = m_ui->m_sensorTypeComboBox->itemText(idx).toStdString();
 
  294   std::map<double, double> srf = getSRFMap(st, stName);
 
  295   std::map<double, double>::iterator it;
 
  298   std::vector<double> wavelengthX;
 
  299   std::vector<double> reflectanceY;
 
  301   for(it = srf.begin(); it != srf.end(); ++it)
 
  303     wavelengthX.push_back(it->first);
 
  304     reflectanceY.push_back(it->second);
 
  307   m_scatterHighRes->setXValues(wavelengthX);
 
  308   m_scatterHighRes->setYValues(reflectanceY);
 
  309   m_scatterHighRes->calculateMinMaxValues();
 
  310   m_scatterChartHighRes->setData();
 
  313   m_chartDisplay->replot();
 
  314   m_chartDisplay->updateLayout();
 
  319   QComboBox* cmbBox = 
dynamic_cast<QComboBox*
>(sender());
 
  323   int row = m_comboMap[cmbBox];
 
  336     scatterChart->setPen(c);
 
  338     scatterChart->setSymbol(0);
 
  339     scatterChart->setStyle(QwtPlotCurve::Lines);
 
  340     scatterChart->attach(m_chartDisplay);
 
  343     QString title(tr(
"Low Resolution - Band "));
 
  344     title.append(QString::number(row));
 
  345     scatterChart->setTitle(title);
 
  347      m_scatterLowResVec[row] = scatter;
 
  348      m_scatterChartLowResVec[row] = scatterChart;
 
  352   std::string stName = cmbBox->itemText(idx).toStdString();
 
  354   std::map<double, double> srf = getSRFMap(st, stName);
 
  355   std::map<double, double>::iterator it;
 
  358   std::vector<double> wavelengthX;
 
  359   std::vector<double> reflectanceY;
 
  361   for(it = srf.begin(); it != srf.end(); ++it)
 
  363     wavelengthX.push_back(it->first);
 
  364     reflectanceY.push_back(it->second);
 
  373   m_chartDisplay->replot();
 
  374   m_chartDisplay->updateLayout();
 
  379   QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open Spectral Response Function File"), 
"", tr(
"CSV Files (*.csv *.CSV)"));
 
  381   if(fileName.isEmpty())
 
  384   int idx = m_ui->m_sensorTypeComboBox->count();
 
  385   m_ui->m_sensorTypeComboBox->addItem(fileName, QVariant(-1));
 
  386   m_ui->m_sensorTypeComboBox->setCurrentIndex(idx);
 
  387   onHighResSensorTypeActivated(idx);
 
  392   QToolButton* button = 
dynamic_cast<QToolButton*
>(sender());
 
  396   int row = m_buttonMap[button];
 
  398   QComboBox* combo = (QComboBox*)m_ui->m_wisperTableWidget->cellWidget(row, 2);
 
  403   QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open Spectral Response Function File"), 
"", tr(
"CSV Files (*.csv *.CSV)"));
 
  405   if(fileName.isEmpty())
 
  408   int idx = combo->count();
 
  409   combo->addItem(fileName, QVariant(-1));
 
  410   combo->setCurrentIndex(idx);
 
  415   m_ui->m_fusionTypeComboBox->clear();
 
  417   m_ui->m_fusionTypeComboBox->addItem(tr(
"IHS"), 
FUSION_IHS);
 
  418   m_ui->m_fusionTypeComboBox->addItem(tr(
"PCA"), 
FUSION_PCA);
 
  419   m_ui->m_fusionTypeComboBox->addItem(tr(
"WISPER"), 
FUSION_WISPER);
 
  421   m_ui->m_interpolatorComboBox->clear();
 
  467   m_ui->m_waveletComboBox->clear();
 
  476   m_ui->m_ihsRComboBox->clear();
 
  477   m_ui->m_ihsGComboBox->clear();
 
  478   m_ui->m_ihsBComboBox->clear();
 
  479   m_ui->m_listWidget->clear();
 
  480   m_ui->m_wisperTableWidget->setRowCount(0);
 
  484   assert(m_layerLower.get());
 
  487   std::auto_ptr<te::da::DataSet> ds = m_layerLower->getData();
 
  493     std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
 
  497       for(
unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
 
  499         m_ui->m_ihsRComboBox->addItem(QString::number(i));
 
  500         m_ui->m_ihsGComboBox->addItem(QString::number(i));
 
  501         m_ui->m_ihsBComboBox->addItem(QString::number(i));
 
  502         m_ui->m_listWidget->addItem(QString::number(i));
 
  505         int newrow = m_ui->m_wisperTableWidget->rowCount();
 
  506         m_ui->m_wisperTableWidget->insertRow(newrow);
 
  508         QString bName(tr(
"Band "));
 
  509         bName.append(QString::number(i));
 
  511         QTableWidgetItem* itemBand = 
new QTableWidgetItem(bName);
 
  512         itemBand->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
 
  513         itemBand->setCheckState(Qt::Checked);
 
  514         m_ui->m_wisperTableWidget->setItem(newrow, 0, itemBand);
 
  517         QToolButton* button = 
new QToolButton(
this);
 
  518         button->setText(
"...");
 
  519         button->setToolTip(tr(
"Open Spectral Response Function File..."));
 
  520         button->resize(16,16);
 
  522         m_ui->m_wisperTableWidget->setCellWidget(newrow, 1, button);
 
  524         connect(button, SIGNAL(clicked()), 
this, SLOT(onLowCsvToolButtonClicked()));
 
  526         m_buttonMap.insert(std::map<QToolButton*, int>::value_type(button, (
int)i));
 
  529         QComboBox* cmbBox = 
new QComboBox(
this);
 
  530         fillSensorTypes(cmbBox);
 
  531         m_ui->m_wisperTableWidget->setCellWidget(newrow, 2, cmbBox);
 
  533         connect(cmbBox, SIGNAL(currentIndexChanged(
int)), 
this, SLOT(onLowResSensorTypeActivated(
int)));
 
  535         m_comboMap.insert(std::map<QComboBox*, int>::value_type(cmbBox, (
int)i));
 
  538       m_scatterLowResVec.resize(inputRst->getNumberOfBands(), 0);
 
  539       m_scatterChartLowResVec.resize(inputRst->getNumberOfBands(), 0);
 
  543   m_ui->m_wisperTableWidget->resizeColumnsToContents();
 
  548   m_ui->m_bandComboBox_IHS->clear();
 
  549   m_ui->m_bandComboBox_PCA->clear();
 
  550   m_ui->m_bandComboBox_Wisper->clear();
 
  552   assert(m_layerHigher.get());
 
  555   std::auto_ptr<te::da::DataSet> ds = m_layerHigher->getData();
 
  561     std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
 
  565       for(
unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
 
  567         m_ui->m_bandComboBox_IHS->addItem(QString::number(i));
 
  568         m_ui->m_bandComboBox_PCA->addItem(QString::number(i));
 
  569         m_ui->m_bandComboBox_Wisper->addItem(QString::number(i));
 
  577   std::map<double, double> srfMap;
 
  581     std::ifstream file(stName.c_str());
 
  589       std::getline(file, buffer);
 
  591       while(std::getline(file, buffer))
 
  593         std::vector<std::string> line;
 
  599           double wavelength = atof(line[0].c_str());
 
  600           double response = atof(line[1].c_str());
 
  602           srfMap.insert(std::map<double, double>::value_type(wavelength, response));
 
te::rp::IHSFusion::InputParameters getInputIHSParams()
 
FusionWizardPage(QWidget *parent=0)
 
te::rp::WisperFusion::OutputParameters getOutputWisperParams()
 
Near neighborhood interpolation method. 
 
void onLowCsvToolButtonClicked()
 
void getSRF(const SensorType &sensor, ContainerT &container)
Returns a Spectral Response Function from the given sensor. 
 
te::qt::widgets::ChartDisplay * m_chartDisplay
 
IHSFusion output parameters. 
 
PCAFusion output parameters. 
 
std::map< double, double > getSRFMap(te::rp::srf::SensorType st, std::string stName)
 
InterpolationMethod
Allowed interpolation methods. 
 
InterpolationMethod Method
Allowed interpolation methods. 
 
WisperFusion output parameters. 
 
te::rp::PCAFusion::OutputParameters getOutputPCAParams()
 
void setLower(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for classifier operation. 
 
void onHighResSensorTypeActivated(int idx)
 
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
 
SensorType
Satellite sensors. 
 
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice. 
 
This file defines a class for a Fusion Wizard page. 
 
te::rp::WisperFusion::InputParameters getInputWisperParams()
 
std::auto_ptr< Ui::FusionWizardPageForm > m_ui
 
WaveletAtrousFilterType
Wavelet Atrous Filter types. 
 
te::rp::IHSFusion::OutputParameters getOutputIHSParams()
 
Bicubic interpolation method. 
 
void fillSensorTypes(QComboBox *combo)
 
void setHigher(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for classifier operation. 
 
void onLowResSensorTypeActivated(int idx)
 
Bilinear interpolation method. 
 
TESEEXPORT std::string GenerateRandomColor()
Creates a random RGB color encoded using two hexadecimal digits per primary-color component prefixed ...
 
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
 
void onHighCsvToolButtonClicked()
 
LANDSAT 7 ETM+ Band 8 PAN. 
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
te::rp::PCAFusion::InputParameters getInputPCAParams()