[pktools] 197/375: commit from pktools
Bas Couwenberg
sebastic at xs4all.nl
Wed Dec 3 21:54:13 UTC 2014
This is an automated email from the git hooks/post-receive script.
sebastic-guest pushed a commit to branch upstream-master
in repository pktools.
commit 0dcb7b59dee4a4bfd0ffbcaea92de930d60ec9ba
Author: Pieter Kempeneers <kempenep at gmail.com>
Date: Fri Mar 21 12:08:15 2014 +0100
commit from pktools
---
README | 2 +-
qt/pkextract/main.cc | 31 ++
qt/pkextract/mainwindow.cc | 34 +++
qt/pkextract/mainwindow.h | 42 +++
qt/pkextract/mainwindow.ui | 24 ++
qt/pkextract/pkextract.pro | 20 ++
qt/pkinfo/main.cpp | 11 +
qt/pkinfo/mainwindow.cpp | 137 +++++++++
qt/pkinfo/mainwindow.h | 37 +++
qt/pkinfo/mainwindow.ui | 727 +++++++++++++++++++++++++++++++++++++++++++++
qt/pkinfo/pkinfo.pro | 20 ++
src/apps/pkclassify_nn.cc | 10 +-
src/apps/pkclassify_svm.cc | 10 +-
src/apps/pkextract.cc | 12 +-
src/apps/pkfs_nn.cc | 19 +-
src/apps/pkfs_svm.cc | 6 +-
src/base/Optionpk.h | 105 ++++++-
17 files changed, 1202 insertions(+), 45 deletions(-)
diff --git a/README b/README
index a00e753..eca0de8 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
Description of pktools
----------------------
-The version of this pktools distribution is 2.4
+The version of this pktools distribution is 2.5.1
pktools is a collection of programs written in C++ to perform operations, mostly on raster images. It heavily relies on the Geospatial Data Abstraction Library (GDAL, http://www.gdal.org) and OGR. The programs are similar to the gdal tools (gdalinfo, gdal_translate, gdal_merge,...) and some of the functionalities provided in pktools already exist in the gdal tools. The reason for implementing pktools is a combination of personal preference and additional functionality.
License and distribution
diff --git a/qt/pkextract/main.cc b/qt/pkextract/main.cc
new file mode 100644
index 0000000..b53cf84
--- /dev/null
+++ b/qt/pkextract/main.cc
@@ -0,0 +1,31 @@
+/**********************************************************************
+main.cc
+Copyright (C) 2008-2014 Pieter Kempeneers
+
+This file is part of pktools
+
+pktools is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+pktools is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with pktools. If not, see <http://www.gnu.org/licenses/>.
+***********************************************************************/
+
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/qt/pkextract/mainwindow.cc b/qt/pkextract/mainwindow.cc
new file mode 100644
index 0000000..791bb0c
--- /dev/null
+++ b/qt/pkextract/mainwindow.cc
@@ -0,0 +1,34 @@
+/**********************************************************************
+mainwindow.cc
+Copyright (C) 2008-2014 Pieter Kempeneers
+
+This file is part of pktools
+
+pktools is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+pktools is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with pktools. If not, see <http://www.gnu.org/licenses/>.
+***********************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
diff --git a/qt/pkextract/mainwindow.h b/qt/pkextract/mainwindow.h
new file mode 100644
index 0000000..c4006c4
--- /dev/null
+++ b/qt/pkextract/mainwindow.h
@@ -0,0 +1,42 @@
+/**********************************************************************
+mainwindow.h
+Copyright (C) 2008-2014 Pieter Kempeneers
+
+This file is part of pktools
+
+pktools is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+pktools is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with pktools. If not, see <http://www.gnu.org/licenses/>.
+***********************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H
diff --git a/qt/pkextract/mainwindow.ui b/qt/pkextract/mainwindow.ui
new file mode 100644
index 0000000..6050363
--- /dev/null
+++ b/qt/pkextract/mainwindow.ui
@@ -0,0 +1,24 @@
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>MainWindow</string>
+ </property>
+ <widget class="QMenuBar" name="menuBar" />
+ <widget class="QToolBar" name="mainToolBar" />
+ <widget class="QWidget" name="centralWidget" />
+ <widget class="QStatusBar" name="statusBar" />
+ </widget>
+ <layoutDefault spacing="6" margin="11" />
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/qt/pkextract/pkextract.pro b/qt/pkextract/pkextract.pro
new file mode 100644
index 0000000..75252b3
--- /dev/null
+++ b/qt/pkextract/pkextract.pro
@@ -0,0 +1,20 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2014-03-20T17:53:10
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = pkextract
+TEMPLATE = app
+
+
+SOURCES += main.cc\
+ mainwindow.cc
+
+HEADERS += mainwindow.h
+
+FORMS += mainwindow.ui
diff --git a/qt/pkinfo/main.cpp b/qt/pkinfo/main.cpp
new file mode 100644
index 0000000..9e2d83c
--- /dev/null
+++ b/qt/pkinfo/main.cpp
@@ -0,0 +1,11 @@
+#include "mainwindow.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+
+ return a.exec();
+}
diff --git a/qt/pkinfo/mainwindow.cpp b/qt/pkinfo/mainwindow.cpp
new file mode 100644
index 0000000..d39fdbc
--- /dev/null
+++ b/qt/pkinfo/mainwindow.cpp
@@ -0,0 +1,137 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+//#include "MyComboBox.h"
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QDir>
+#include <QProcess>
+#include <QDebug>
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::on_button_input_clicked()
+{
+ MainWindow::on_menu_input_triggered();
+}
+
+void MainWindow::on_pushButton_Run_clicked()
+{
+ ui->outputEdit->clear();
+ ui->commandLineEdit->clear();
+
+ QObject *parent;
+
+ try{
+ QString program = "pkinfo";
+ if(m_inputFilename.isEmpty())
+ MainWindow::on_menu_input_triggered();
+
+ if(m_inputFilename.isEmpty()){
+ QString qsError="No input image selected";
+ throw(qsError);
+ }
+ program+=" --input ";
+ program+=m_inputFilename;
+
+ QList<QCheckBox*> qcheckBoxList = this->findChildren<QCheckBox *>();
+
+ for(QList<QCheckBox*>::ConstIterator qcbit=qcheckBoxList.begin();qcbit!=qcheckBoxList.end();++qcbit){
+ if((*qcbit)->isChecked()){
+ QString qsOption;
+ qsOption+=" --";
+ qsOption+=(*qcbit)->objectName();
+ program+=qsOption;
+ }
+ }
+
+ QList<QComboBox*> qcomboBoxList = this->findChildren<QComboBox *>();
+
+ for(QList<QComboBox*>::ConstIterator qcbit=qcomboBoxList.begin();qcbit!=qcomboBoxList.end();++qcbit){
+ QString qsOption;
+ qsOption+=" --";
+ qsOption+=(*qcbit)->objectName();
+ program+=qsOption;
+ program+=" ";
+ program+=QString::number((*qcbit)->currentIndex());
+ }
+
+ QList<QLineEdit*> qlineEditList = this->findChildren<QLineEdit *>();
+
+ for(QList<QLineEdit*>::ConstIterator qlbit=qlineEditList.begin();qlbit!=qlineEditList.end();++qlbit){
+ if(!((*qlbit)->text().isEmpty())){
+ QString qsOption;
+ qsOption+=" --";
+ qsOption+=(*qlbit)->objectName();
+ qsOption+=" ";
+ qsOption+=(*qlbit)->text();
+ program+=qsOption;
+ }
+ }
+
+ ui->commandLineEdit->insertPlainText(program);
+
+ QProcess *myProcess = new QProcess(parent);
+ myProcess->start(program);
+ myProcess->waitForFinished(-1);
+ QString p_stdout = myProcess->readAll();
+ ui->outputEdit->appendPlainText(p_stdout);
+ delete myProcess;
+ }
+ catch(QString qsError){
+ QMessageBox msgBox;
+ msgBox.setText(qsError);
+ msgBox.exec();
+ }
+}
+
+void MainWindow::on_pushButton_clearOutput_clicked()
+{
+ ui->outputEdit->clear();
+}
+
+void MainWindow::on_pushButton_clearCommandLine_clicked()
+{
+ ui->commandLineEdit->clear();
+}
+
+void MainWindow::on_menu_input_triggered()
+{
+ QObject *parent;
+ QProcess *myProcess = new QProcess(parent);
+ QString program;
+ m_inputFilename = QFileDialog::getOpenFileName(this, "Input image","/tmp");
+ if ( m_inputFilename.isNull() == false ){
+ //fill in combobox with number of bands
+ program="pkinfo -nb -i ";
+ program+=m_inputFilename;
+ myProcess->start(program);
+ myProcess->waitForFinished(-1);
+ QString p_stdout = myProcess->readAll();
+ qDebug() << p_stdout;
+ int nband=p_stdout.section(' ',1).toInt();
+ QStringList list;
+ for(int iband=0;iband<nband;++iband){
+ QString qsband="band";
+ qsband+=QString::number(iband);
+ list.append(qsband);
+ }
+ ui->band->addItems(list);
+ }
+ delete myProcess;
+}
+
+void MainWindow::on_actionQuit_triggered()
+{
+ close();
+}
diff --git a/qt/pkinfo/mainwindow.h b/qt/pkinfo/mainwindow.h
new file mode 100644
index 0000000..4a74968
--- /dev/null
+++ b/qt/pkinfo/mainwindow.h
@@ -0,0 +1,37 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private slots:
+
+ void on_pushButton_Run_clicked();
+
+ void on_button_input_clicked();
+
+ void on_pushButton_clearOutput_clicked();
+
+ void on_pushButton_clearCommandLine_clicked();
+
+ void on_menu_input_triggered();
+
+ void on_actionQuit_triggered();
+
+private:
+ Ui::MainWindow *ui;
+ QString m_inputFilename;
+};
+
+#endif // MAINWINDOW_H
diff --git a/qt/pkinfo/mainwindow.ui b/qt/pkinfo/mainwindow.ui
new file mode 100644
index 0000000..f0a979c
--- /dev/null
+++ b/qt/pkinfo/mainwindow.ui
@@ -0,0 +1,727 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>664</width>
+ <height>898</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>pkinfo</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <widget class="QPushButton" name="pushButton_clearOutput">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>790</y>
+ <width>105</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="button_input">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>0</y>
+ <width>97</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Input image...</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButton_Run">
+ <property name="geometry">
+ <rect>
+ <x>490</x>
+ <y>0</y>
+ <width>105</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Run</string>
+ </property>
+ </widget>
+ <widget class="QPlainTextEdit" name="outputEdit">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>661</y>
+ <width>591</width>
+ <height>121</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>630</y>
+ <width>66</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Output</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_4">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>460</y>
+ <width>101</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Command line</string>
+ </property>
+ </widget>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>581</width>
+ <height>411</height>
+ </rect>
+ </property>
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <widget class="QWidget" name="datasetinfo">
+ <attribute name="title">
+ <string>general</string>
+ </attribute>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>9</x>
+ <y>10</y>
+ <width>207</width>
+ <height>220</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="nband">
+ <property name="text">
+ <string>number of bands</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="ns">
+ <property name="text">
+ <string>number of samples</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="nl">
+ <property name="text">
+ <string>number of lines</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="interleave">
+ <property name="text">
+ <string>band encoding (interleave)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="otype">
+ <property name="text">
+ <string>data type</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="description">
+ <property name="text">
+ <string>image description</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>geo</string>
+ </attribute>
+ <widget class="QCheckBox" name="cover">
+ <property name="geometry">
+ <rect>
+ <x>190</x>
+ <y>80</y>
+ <width>111</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>covers area</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="ulx">
+ <property name="geometry">
+ <rect>
+ <x>320</x>
+ <y>60</y>
+ <width>113</width>
+ <height>33</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_5">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>40</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>upper left x</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_6">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>40</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>upper left y</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="uly">
+ <property name="geometry">
+ <rect>
+ <x>440</x>
+ <y>60</y>
+ <width>113</width>
+ <height>33</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_7">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>90</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>lower right x</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_8">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>90</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>lower right y</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="lry">
+ <property name="geometry">
+ <rect>
+ <x>440</x>
+ <y>110</y>
+ <width>113</width>
+ <height>33</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="lrx">
+ <property name="geometry">
+ <rect>
+ <x>320</x>
+ <y>110</y>
+ <width>113</width>
+ <height>33</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="xpos">
+ <property name="geometry">
+ <rect>
+ <x>320</x>
+ <y>170</y>
+ <width>113</width>
+ <height>33</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_9">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>150</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>position x</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="ypos">
+ <property name="geometry">
+ <rect>
+ <x>440</x>
+ <y>170</y>
+ <width>113</width>
+ <height>33</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_10">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>150</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>position y</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="read">
+ <property name="geometry">
+ <rect>
+ <x>190</x>
+ <y>170</y>
+ <width>121</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="toolTip">
+ <string><html><head/><body><p>position in image coordinates (col, row), unless geotransform is selected</p></body></html></string>
+ </property>
+ <property name="text">
+ <string>read data at:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_15">
+ <property name="geometry">
+ <rect>
+ <x>400</x>
+ <y>10</y>
+ <width>66</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Set area:</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButton_extent">
+ <property name="geometry">
+ <rect>
+ <x>440</x>
+ <y>220</y>
+ <width>97</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Browse...</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_16">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>220</y>
+ <width>161</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Set area via vector file:</string>
+ </property>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>10</y>
+ <width>152</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="dx">
+ <property name="text">
+ <string>cell size in x</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="dy">
+ <property name="text">
+ <string>cell size in y</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="bbox">
+ <property name="text">
+ <string>bounding box</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="centre">
+ <property name="text">
+ <string>image center</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="ref">
+ <property name="text">
+ <string>reference pixel
+(center of gravity)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="a_srs">
+ <property name="text">
+ <string>projection info</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="geo">
+ <property name="text">
+ <string>geotransform</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <zorder>layoutWidget</zorder>
+ <zorder>cover</zorder>
+ <zorder>ulx</zorder>
+ <zorder>label_5</zorder>
+ <zorder>label_6</zorder>
+ <zorder>uly</zorder>
+ <zorder>label_7</zorder>
+ <zorder>label_8</zorder>
+ <zorder>lry</zorder>
+ <zorder>lrx</zorder>
+ <zorder>xpos</zorder>
+ <zorder>label_9</zorder>
+ <zorder>ypos</zorder>
+ <zorder>label_10</zorder>
+ <zorder>read</zorder>
+ <zorder>label_15</zorder>
+ <zorder>pushButton_extent</zorder>
+ <zorder>label_16</zorder>
+ </widget>
+ <widget class="QWidget" name="tab_3">
+ <attribute name="title">
+ <string>stats</string>
+ </attribute>
+ <widget class="QCheckBox" name="minmax">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>120</y>
+ <width>171</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>minimum and maximum</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="min">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>150</y>
+ <width>91</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>minimum </string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="max">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>180</y>
+ <width>91</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>maximum</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="band_label">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>91</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>input band(s)</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="nbin">
+ <property name="geometry">
+ <rect>
+ <x>340</x>
+ <y>210</y>
+ <width>41</width>
+ <height>33</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="stats">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>60</y>
+ <width>141</width>
+ <height>26</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>basic statistics</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_13">
+ <property name="geometry">
+ <rect>
+ <x>260</x>
+ <y>60</y>
+ <width>111</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>source minimum</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="src_min">
+ <property name="geometry">
+ <rect>
+ <x>370</x>
+ <y>50</y>
+ <width>41</width>
+ <height>33</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="src_max">
+ <property name="geometry">
+ <rect>
+ <x>370</x>
+ <y>100</y>
+ <width>41</width>
+ <height>33</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_14">
+ <property name="geometry">
+ <rect>
+ <x>260</x>
+ <y>100</y>
+ <width>111</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>source maximum</string>
+ </property>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>210</y>
+ <width>327</width>
+ <height>28</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="hist">
+ <property name="text">
+ <string>histogram</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rel">
+ <property name="text">
+ <string>relative (in %)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_nbin">
+ <property name="text">
+ <string>number of bins</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QLabel" name="label_17">
+ <property name="geometry">
+ <rect>
+ <x>260</x>
+ <y>150</y>
+ <width>111</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>nodata value</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="nodata">
+ <property name="geometry">
+ <rect>
+ <x>370</x>
+ <y>150</y>
+ <width>41</width>
+ <height>33</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="band">
+ <property name="geometry">
+ <rect>
+ <x>120</x>
+ <y>20</y>
+ <width>83</width>
+ <height>29</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QPlainTextEdit" name="commandLineEdit">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>490</y>
+ <width>591</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property name="plainText">
+ <string/>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButton_clearCommandLine">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>560</y>
+ <width>105</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>664</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>File</string>
+ </property>
+ <addaction name="menu_input"/>
+ <addaction name="actionQuit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ <action name="menu_input">
+ <property name="text">
+ <string>Input image</string>
+ </property>
+ </action>
+ <action name="actionQuit">
+ <property name="text">
+ <string>Quit</string>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/qt/pkinfo/pkinfo.pro b/qt/pkinfo/pkinfo.pro
new file mode 100644
index 0000000..02495e8
--- /dev/null
+++ b/qt/pkinfo/pkinfo.pro
@@ -0,0 +1,20 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2014-03-20T15:39:07
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = pkinfo
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+
+FORMS += mainwindow.ui
diff --git a/src/apps/pkclassify_nn.cc b/src/apps/pkclassify_nn.cc
index 01337ad..c4eefd4 100644
--- a/src/apps/pkclassify_nn.cc
+++ b/src/apps/pkclassify_nn.cc
@@ -18,10 +18,6 @@ You should have received a copy of the GNU General Public License
along with pktools. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#include <stdlib.h>
-#ifdef WIN32
-#define random rand
-#define srandom srand
-#endif
#include <vector>
#include <map>
#include <algorithm>
@@ -46,6 +42,7 @@ int main(int argc, char *argv[])
Optionpk<string> training_opt("t", "training", "training shape file. A single shape file contains all training features (must be set as: B0, B1, B2,...) for all classes (class numbers identified by label option). Use multiple training files for bootstrap aggregation (alternative to the bag and bsize options, where a random subset is taken from a single training file)");
Optionpk<string> label_opt("label", "label", "identifier for class label in training shape file.","label");
Optionpk<unsigned int> balance_opt("bal", "balance", "balance the input data to this number of samples for each class", 0);
+ Optionpk<bool> random_opt("random", "random", "in case of balance, randomize input data", true);
Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account (0: consider all classes)", 0);
Optionpk<double> start_opt("s", "start", "start band sequence number (set to 0)",0);
Optionpk<double> end_opt("e", "end", "end band sequence number (set to 0 for all bands)", 0);
@@ -88,6 +85,7 @@ int main(int argc, char *argv[])
training_opt.retrieveOption(argc,argv);
label_opt.retrieveOption(argc,argv);
balance_opt.retrieveOption(argc,argv);
+ random_opt.retrieveOption(argc,argv);
minSize_opt.retrieveOption(argc,argv);
start_opt.retrieveOption(argc,argv);
end_opt.retrieveOption(argc,argv);
@@ -266,7 +264,7 @@ int main(int argc, char *argv[])
if(balance_opt[0]>0){
while(balance_opt.size()<nclass)
balance_opt.push_back(balance_opt.back());
- if(random)
+ if(random_opt[0])
srand(time(NULL));
totalSamples=0;
for(int iclass=0;iclass<nclass;++iclass){
@@ -392,7 +390,7 @@ int main(int argc, char *argv[])
int nctraining=0;
if(verbose_opt[0]>=1)
cout << "calculating features for class " << iclass << endl;
- if(random)
+ if(random_opt[0])
srand(time(NULL));
nctraining=(bagSize_opt[iclass]<100)? trainingPixels[iclass].size()/100.0*bagSize_opt[iclass] : trainingPixels[iclass].size();//bagSize_opt[iclass] given in % of training size
if(nctraining<=0)
diff --git a/src/apps/pkclassify_svm.cc b/src/apps/pkclassify_svm.cc
index e5d7896..b428f95 100644
--- a/src/apps/pkclassify_svm.cc
+++ b/src/apps/pkclassify_svm.cc
@@ -18,10 +18,6 @@ You should have received a copy of the GNU General Public License
along with pktools. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#include <stdlib.h>
-#ifdef WIN32
-#define random rand
-#define srandom srand
-#endif
#include <vector>
#include <map>
#include <algorithm>
@@ -56,6 +52,7 @@ int main(int argc, char *argv[])
Optionpk<string> training_opt("t", "training", "training shape file. A single shape file contains all training features (must be set as: B0, B1, B2,...) for all classes (class numbers identified by label option). Use multiple training files for bootstrap aggregation (alternative to the bag and bsize options, where a random subset is taken from a single training file)");
Optionpk<string> label_opt("label", "label", "identifier for class label in training shape file.","label");
Optionpk<unsigned int> balance_opt("bal", "balance", "balance the input data to this number of samples for each class", 0);
+ Optionpk<bool> random_opt("random", "random", "in case of balance, randomize input data", true);
Optionpk<int> minSize_opt("min", "min", "if number of training pixels is less then min, do not take this class into account (0: consider all classes)", 0);
Optionpk<double> start_opt("s", "start", "start band sequence number (set to 0)",0);
Optionpk<double> end_opt("e", "end", "end band sequence number (set to 0 for all bands)", 0);
@@ -104,6 +101,7 @@ int main(int argc, char *argv[])
training_opt.retrieveOption(argc,argv);
label_opt.retrieveOption(argc,argv);
balance_opt.retrieveOption(argc,argv);
+ random_opt.retrieveOption(argc,argv);
minSize_opt.retrieveOption(argc,argv);
start_opt.retrieveOption(argc,argv);
end_opt.retrieveOption(argc,argv);
@@ -316,7 +314,7 @@ int main(int argc, char *argv[])
if(balance_opt[0]>0){
while(balance_opt.size()<nclass)
balance_opt.push_back(balance_opt.back());
- if(random)
+ if(random_opt[0])
srand(time(NULL));
totalSamples=0;
for(short iclass=0;iclass<nclass;++iclass){
@@ -443,7 +441,7 @@ int main(int argc, char *argv[])
int nctraining=0;
if(verbose_opt[0]>=1)
std::cout << "calculating features for class " << iclass << std::endl;
- if(random)
+ if(random_opt[0])
srand(time(NULL));
nctraining=(bagSize_opt[iclass]<100)? trainingPixels[iclass].size()/100.0*bagSize_opt[iclass] : trainingPixels[iclass].size();//bagSize_opt[iclass] given in % of training size
if(nctraining<=0)
diff --git a/src/apps/pkextract.cc b/src/apps/pkextract.cc
index d893ee2..889faf4 100644
--- a/src/apps/pkextract.cc
+++ b/src/apps/pkextract.cc
@@ -20,10 +20,6 @@ along with pktools. If not, see <http://www.gnu.org/licenses/>.
#include <assert.h>
#include <math.h>
#include <stdlib.h>
-#ifdef WIN32
-#define random rand
-#define srandom srand
-#endif
#include <sstream>
#include <string>
#include <algorithm>
@@ -246,7 +242,7 @@ int main(int argc, char *argv[])
void* pProgressArg=NULL;
GDALProgressFunc pfnProgress=GDALTermProgress;
double progress=0;
- srandom(time(NULL));
+ srand(time(NULL));
bool sampleIsRaster=false;
ImgReaderOgr sampleReaderOgr;
@@ -427,7 +423,7 @@ int main(int argc, char *argv[])
}
float theThreshold=(threshold_opt.size()>1)?threshold_opt[processClass]:threshold_opt[0];
if(theThreshold>0){//percentual value
- double p=static_cast<double>(random())/(RAND_MAX);
+ double p=static_cast<double>(rand())/(RAND_MAX);
p*=100.0;
if(p>theThreshold)
continue;//do not select for now, go to next column
@@ -671,7 +667,7 @@ int main(int argc, char *argv[])
}
float theThreshold=(threshold_opt.size()>1)?threshold_opt[processClass]:threshold_opt[0];
if(theThreshold>0){//percentual value
- double p=static_cast<double>(random())/(RAND_MAX);
+ double p=static_cast<double>(rand())/(RAND_MAX);
p*=100.0;
if(p>theThreshold)
continue;//do not select for now, go to next column
@@ -891,7 +887,7 @@ int main(int argc, char *argv[])
if(verbose_opt[0]>0)
std::cout << "reading feature " << readFeature->GetFID() << std::endl;
if(threshold_opt[0]>0){//percentual value
- double p=static_cast<double>(random())/(RAND_MAX);
+ double p=static_cast<double>(rand())/(RAND_MAX);
p*=100.0;
if(p>threshold_opt[0]){
if(test_opt.size())
diff --git a/src/apps/pkfs_nn.cc b/src/apps/pkfs_nn.cc
index 6ac56b2..4a8c939 100644
--- a/src/apps/pkfs_nn.cc
+++ b/src/apps/pkfs_nn.cc
@@ -18,10 +18,6 @@ You should have received a copy of the GNU General Public License
along with pktools. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#include <stdlib.h>
-#ifdef WIN32
-#define random rand
-#define srandom srand
-#endif
#include <vector>
#include <string>
#include <map>
@@ -162,11 +158,6 @@ double getCost(const vector<Vector2d<float> > &trainingFeatures)
else{//not working yet. please repair...
assert(cv_opt[0]>0);
bool initWeights=true;
- //test
- cout << "tempFeatures.size(): " << tmpFeatures.size() << endl;
- cout << "ntraining: " << ntraining << endl;
- cout << "initWeights: " << initWeights << endl;
- cout << "maxit_opt.size(): " << maxit_opt.size() << endl;
net.train_on_data(tmpFeatures,ntraining,initWeights, maxit_opt[0],
iterations_between_reports, desired_error);
vector<Vector2d<float> > testFeatures(nclass);
@@ -178,8 +169,6 @@ double getCost(const vector<Vector2d<float> > &trainingFeatures)
for(int ifeature=0;ifeature<nFeatures;++ifeature){
testFeatures[iclass][isample][ifeature]=trainingFeatures[iclass][nctraining[iclass]+isample][ifeature];
}
- //test
- cout << "isample:" << isample<< endl;
result=net.run(testFeatures[iclass][isample]);
string refClassName=nameVector[iclass];
float maxP=-1;
@@ -190,19 +179,13 @@ double getCost(const vector<Vector2d<float> > &trainingFeatures)
maxClass=ic;
}
}
- //test
- cout << "maxClass:" << maxClass << "(" << nameVector.size() << ")" << endl;
string className=nameVector[maxClass];
- //test
- cout << "className:" << nameVector[maxClass] << endl;
if(classValueMap.size())
cm.incrementResult(type2string<short>(classValueMap[refClassName]),type2string<short>(classValueMap[className]),1.0);
else
cm.incrementResult(cm.getClass(referenceVector[isample]),cm.getClass(outputVector[isample]),1.0);
}
}
- //test
- cout << "debug12" << endl;
}
assert(cm.nReference());
return(cm.kappa());
@@ -237,7 +220,7 @@ int main(int argc, char *argv[])
maxFeatures_opt.retrieveOption(argc,argv);
label_opt.retrieveOption(argc,argv);
balance_opt.retrieveOption(argc,argv);
- random_opt.retrieveOption(argc,argv);
+ random_opt.retrieveOption(argc,argv);
minSize_opt.retrieveOption(argc,argv);
start_opt.retrieveOption(argc,argv);
end_opt.retrieveOption(argc,argv);
diff --git a/src/apps/pkfs_svm.cc b/src/apps/pkfs_svm.cc
index 45f8996..65c6cab 100644
--- a/src/apps/pkfs_svm.cc
+++ b/src/apps/pkfs_svm.cc
@@ -18,10 +18,6 @@ You should have received a copy of the GNU General Public License
along with pktools. If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/
#include <stdlib.h>
-#ifdef WIN32
-#define random rand
-#define srandom srand
-#endif
#include <vector>
#include <string>
#include <map>
@@ -246,7 +242,7 @@ int main(int argc, char *argv[])
maxFeatures_opt.retrieveOption(argc,argv);
label_opt.retrieveOption(argc,argv);
balance_opt.retrieveOption(argc,argv);
- random_opt.retrieveOption(argc,argv);
+ random_opt.retrieveOption(argc,argv);
minSize_opt.retrieveOption(argc,argv);
start_opt.retrieveOption(argc,argv);
end_opt.retrieveOption(argc,argv);
diff --git a/src/base/Optionpk.h b/src/base/Optionpk.h
index 9c07f43..1905978 100644
--- a/src/base/Optionpk.h
+++ b/src/base/Optionpk.h
@@ -31,6 +31,9 @@ along with pktools. If not, see <http://www.gnu.org/licenses/>.
#include <typeinfo>
#ifndef WIN32
#include <cxxabi.h>
+#define mytypeid(T) abi::__cxa_demangle(typeid(T).name(),0,0,&status)
+#else
+#define mytypeid(T) typeid(T).name()
#endif
#include "ogr_feature.h"
@@ -236,7 +239,7 @@ template<class T> inline std::string Optionpk<T>::usageDoxygen() const
else
helpss << std::setiosflags(std::ios::left) << " | ";
int status;
- helpss << std::setiosflags(std::ios::left) << std::setw(4) << typeid(T).name() << " | ";
+ helpss << std::setiosflags(std::ios::left) << std::setw(4) << mytypeid(T) << " | ";
//helpss << std::setiosflags(std::ios::left) << std::setw(4) << abi::__cxa_demangle(typeid(T).name(),0,0,&status) << " | ";
if(m_hasDefault)
helpss <<std::setiosflags(std::ios::left) << std::setw(5) << type2string<T>(m_defaultValue) << " |";
@@ -345,4 +348,104 @@ template<class T> inline bool Optionpk<T>::retrieveOption(int argc, char **argv)
//template<class T> typename std::vector<T>::const_iterator Optionpk<T>::findSubstring(const T& argument) const {std::string errorString="Error: findSubstring only defined for options of type std::string"; throw(errorString);}
+//todo: to be put in .cc file
+/////////////////// Specializations /////////////////
+
+///specialization for string
+template<> inline std::string string2type(std::string const& s){
+ return s;
+}
+
+///specialization for OGRFieldType
+template<> inline OGRFieldType string2type(std::string const& s){
+ OGRFieldType ftype;
+ int ogr_typecount=11;//hard coded for now!
+ for(int iType = 0; iType < ogr_typecount; ++iType){
+ if( OGRFieldDefn::GetFieldTypeName((OGRFieldType)iType) != NULL
+ && EQUAL(OGRFieldDefn::GetFieldTypeName((OGRFieldType)iType),s.c_str()))
+ ftype=(OGRFieldType) iType;
+ }
+ return ftype;
+}
+
+///specialization for bool
+template<> inline std::string type2string(bool const& value){
+ if(value)
+ return("true");
+ else
+ return("false");
+}
+
+///specialization for string
+template<> inline std::string type2string(std::string const& value){
+ // if(value.empty())
+ // return("<empty string>");
+ // else
+ return(value);
+}
+
+///specialization for float
+template<> inline std::string type2string(float const& value){
+ std::ostringstream oss;
+ // oss.precision(1);
+ // oss.setf(ios::fixed);
+ oss << value;
+ return oss.str();
+}
+
+///specialization for double
+template<> inline std::string type2string(double const& value){
+ std::ostringstream oss;
+ // oss.precision(1);
+ // oss.setf(ios::fixed);
+ oss << value;
+ return oss.str();
+}
+
+///specialization for bool
+template<> inline void Optionpk<bool>::setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo)
+{
+ m_shortName=shortName;
+ m_longName=longName;
+ m_hasArgument=false;
+ m_help=helpInfo;
+ m_hide=0;
+}
+
+///specialization for bool
+template<> inline void Optionpk<bool>::setAll(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const bool& defaultValue, short hide)
+{
+ m_shortName=shortName;
+ m_longName=longName;
+ m_hasArgument=false;
+ m_help=helpInfo;
+ m_defaultValue=defaultValue;
+ m_hasDefault=true;
+ m_hide=hide;
+}
+
+///specialization for bool
+template<> inline Optionpk<bool>::Optionpk(const std::string& shortName, const std::string& longName, const std::string& helpInfo)
+{
+ setAll(shortName,longName,helpInfo);
+}
+
+///specialization for bool
+template<> inline Optionpk<bool>::Optionpk(const std::string& shortName, const std::string& longName, const std::string& helpInfo,const bool& defaultValue, short hide)
+{
+ setAll(shortName,longName,helpInfo,defaultValue, hide);
+}
+
+//specialization (only makes sense for T=std::string), generic function throws exception
+//find a substring in string option (e.g., option is of type -co INTERLEAVE=BAND)
+template<> inline std::vector<std::string>::const_iterator Optionpk<std::string>::findSubstring(const std::string& argument) const{
+ std::vector<std::string>::const_iterator opit=this->begin();
+ while(opit!=this->end()){
+ if(opit->find(argument)!=std::string::npos)
+ break;
+ ++opit;
+ }
+ return opit;
+}
+
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git
More information about the Pkg-grass-devel
mailing list