Commit 207b7e41 authored by Guillaume Pasero's avatar Guillaume Pasero

MRG: Merge bugfixes from 'release-6.0' into develop

parents 81508e19 ffc9c6c9
......@@ -6,7 +6,8 @@ refers to techniques aiming at extracting added value information from
images. These extracted items named *features* can be local statistical
moments, edges, radiometric indices, morphological and textural
properties. For example, such features can be used as input data for
other image processing methods like *Segmentation* and *Classification*.
other image processing methods like *Segmentation* and
`Classification <https://www.orfeo-toolbox.org/CookBook/recipes/pbclassif.html#feature-classification>`_ .
Local statistics extraction
---------------------------
......
Classification
==============
Feature classification and training
-----------------------------------
The Orfeo ToolBox provided applications to train a supervised
or unsupervised classifier from different set of *features*
and to use the generated classifier for vector data classification.
Those *features* can be information extracted from images
(see `feature extraction <https://www.orfeo-toolbox.org/CookBook/recipes/featextract.html#feature-extraction>`_ section)
or it can be different types of *features* such as the perimeter, width,
or area of a surface present in a vector data file in an ogr compatible
format.
Train a classifier with features
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The *TrainVectorClassifier* application provide a way to train a classifier
with an input set of labeled geometries and a list of *features* to consider
for classification.
::
otbcli_TrainVectorClassifier -io.vd samples.sqlite
-cfield CODE
-io.out model.rf
-classifier rf
-feat perimeter area width
The ``-classifier`` parameter allows to choose which machine learning
model algorithm to train. You have the possibility to do the unsupervised
classification,for it, you must to choose the Shark kmeans classifier.
Please refer to the ``TrainVectorClassifier`` application reference documentation.
In case of multiple samples files, you can add them to the ``-io.vd``
parameter.
The feature to be used for training must be explicitly listed using
the ``-feat`` parameter. Order of the list matters.
If you want to use a statistic file for features normalization, you
can pass it using the ``-io.stats`` parameter. Make sure that the
order of feature statistics in the statistics file matches the order
of feature passed to the ``-feat`` option.
The field in vector data allowing to specify the label of each sample
can be set using the ``-cfield`` option.
By default, the application will estimate the trained classifier
performances on the same set of samples that has been used for
training. The ``-io.vd`` parameter allows to specify a different
samples file for this purpose, for a more fair estimation of the
performances. Note that this performances estimation scheme can also
be estimated afterward (see `Validating the classification model`_
section).
Features classification
~~~~~~~~~~~~~~~~~~~~~~~
Once the classifier has been trained, one can apply the model to
classify a set of features on a new vector data file using the
*VectorClassifier* application:
::
otbcli_VectorClassifier -in vectorData.shp
-model model.rf
-feat perimeter area width
-cfield predicted
-out classifiedData.shp
This application output a vector data file storing sample values
and classification label. The output is optional, in this case the
input vector data classification label field is updated.
Validating classification
~~~~~~~~~~~~~~~~~~~~~~~~~
The performance of the model generated by the *TrainVectorClassifier*
or *TrainImagesClassifier* applications is directly estimated by the
application itself, which displays the precision, recall and F-score
of each class, and can generate the global confusion matrix for
supervised algorithms. For unsupervised algorithms a contingency table
is generated. Those results are output as an \*.CSV file.
Pixel based classification
--------------------------
......@@ -346,33 +430,11 @@ using the ``TrainVectorClassifier`` application.
-classifier rf
-feat band_0 band_1 band_2 band_3 band_4 band_5 band_6
The ``-classifier`` parameter allows to choose which machine learning
model algorithm to train. You have the possibility to do the unsupervised
classification,for it, you must to choose the Shark kmeans classifier.
Please refer to the ``TrainVectorClassifier`` application reference documentation.
In case of multiple samples files, you can add them to the ``-io.vd``
parameter (see `Working with several images`_ section).
The feature to be used for training must be explicitly listed using
the ``-feat`` parameter. Order of the list matters.
If you want to use a statistic file for features normalization, you
can pass it using the ``-io.stats`` parameter. Make sure that the
order of feature statistics in the statistics file matches the order
of feature passed to the ``-feat`` option.
The field in vector data allowing to specify the label of each sample
can be set using the ``-cfield`` option.
By default, the application will estimate the trained classifier
performances on the same set of samples that has been used for
training. The ``-io.vd`` parameter allows to specify a different
samples file for this purpose, for a more fair estimation of the
performances. Note that this performances estimation scheme can also
be estimated afterward (see `Validating the classification model`_
section).
For more information about the training process for features
please refer to the `Train a classifier with features`_ section.
Using the classification model
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -395,10 +457,8 @@ with value >0.
Validating the classification model
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The performance of the model generated by the *TrainImagesClassifier*
application is directly estimated by the application itself, which
displays the precision, recall and F-score of each class, and can
generate the global confusion matrix as an output \*.CSV file.
The Orfeo ToolBox training applications provides information about the performance
of the generated model (see `Validating classification`_ ).
With the *ConputeConfusionMatrix* application, it is also possible to
estimate the performance of a model from a classification map generated
......
Adamo Ferro,
Aik Song Chia (CRISP),
Alexia Mondot (CS),
Alexis Huck (Magellium),
Amit Kulkarni,
Andreas Tile (Debian GIS),
......@@ -34,6 +35,7 @@ Laurentiu Nicola (CS Romania),
Luc Hermitte (CS),
Ludovic Hussonnois (CS),
Manuel Grizonnet (CNES),
Marina Bertolino (CNES),
Massimo Di Stefano,
Mathieu Deltorre (CS),
Miarintsoa Ramanantsimiavona,
......
......@@ -393,10 +393,11 @@ following:
\item{Version 5.X (2015 and later):}
\begin{itemize}
\item Modularization
\item Support Spuperbuild mechanism to build OTB and all dependencies
\item Support Superbuild mechanism to build OTB and all dependencies
from source
\item No more internal versions of most third parties
\item Monteverdi as a module in OTB
\item introduction of the MPI support
\end{itemize}
\end{itemize}
......
......@@ -132,7 +132,7 @@ See table \ref{tab:otb-dependencies} for the full list of dependencies.
\hline
\textbf{SiftFast} & \url{http://libsift.sourceforge.net} & no & - \\
\hline
\textbf{SPTW} & \url{https://github.com/kornholi/sptw.git} & no & - \\
\textbf{SPTW} & \url{https://github.com/remicres/sptw.git} & no & - \\
\hline
\end{tabular}
......
......@@ -52,6 +52,9 @@ contain the following actions:
\item Set the name and the description of the application
\item Fill the documentation and give an example
\item Declare all the parameters
\item Define the documentation link:
\item for contrib application use SetDocLink("\textit{docLink}") function defined in \doxygen{otb}{Wrapper::Application}
\item for official application use SetOfficialDocLink() function defined in \doxygen{otb}{Wrapper::Application}
\end{itemize}
......
......@@ -105,6 +105,8 @@ private:
SetDocExampleParameterValue("in1", "Spot5-Gloucester-before.tif");
SetDocExampleParameterValue("in2", "Spot5-Gloucester-after.tif");
SetDocExampleParameterValue("out", "detectedChangeImage.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -121,6 +121,8 @@ private:
SetDocExampleParameterValue("ip.onlyisolatedpixels", "true");
SetDocExampleParameterValue("ip.nodatalabel", "10");
SetDocExampleParameterValue("ip.undecidedlabel", "7");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -31,6 +31,8 @@
#include "otbContingencyTableCalculator.h"
#include "otbContingencyTable.h"
#include "otbMacro.h"
namespace otb
{
namespace Wrapper
......@@ -82,13 +84,14 @@ public:
typedef ContingencyTable<ClassLabelType> ContingencyTableType;
typedef ContingencyTableType::Pointer ContingencyTablePointerType;
protected:
ComputeConfusionMatrix()
{
m_Input = ITK_NULLPTR;
}
private:
Int32ImageType* m_Input;
Int32ImageType::Pointer m_Reference;
RAMDrivenAdaptativeStreamingManagerType::Pointer m_StreamingManager;
otb::ogr::DataSource::Pointer m_OgrRef;
RasterizeFilterType::Pointer m_RasterizeReference;
struct StreamingInitializationData
{
......@@ -176,6 +179,8 @@ private:
SetDocExampleParameterValue("ref.vector.in","VectorData_QB1_bis.shp");
SetDocExampleParameterValue("ref.vector.field","Class");
SetDocExampleParameterValue("ref.vector.nodata","255");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......@@ -317,7 +322,7 @@ private:
sid.refhasnodata = true;
sid.refnodata = this->GetParameterInt("ref.vector.nodata");
m_OgrRef = otb::ogr::DataSource::New(GetParameterString("ref.vector.in"), otb::ogr::DataSource::Modes::Read);
otb::ogr::DataSource::Pointer ogrRef = otb::ogr::DataSource::New(GetParameterString("ref.vector.in"), otb::ogr::DataSource::Modes::Read);
// Get field name
std::vector<int> selectedCFieldIdx = GetSelectedItems("ref.vector.field");
......@@ -331,7 +336,7 @@ private:
field = cFieldNames[selectedCFieldIdx.front()];
m_RasterizeReference = RasterizeFilterType::New();
m_RasterizeReference->AddOGRDataSource(m_OgrRef);
m_RasterizeReference->AddOGRDataSource(ogrRef);
m_RasterizeReference->SetOutputParametersFromImage(m_Input);
m_RasterizeReference->SetBackgroundValue(sid.refnodata);
m_RasterizeReference->SetBurnAttribute(field.c_str());
......@@ -623,6 +628,10 @@ private:
ConfusionMatrixType m_MatrixLOG;
OutputConfusionMatrixType m_Matrix;
Int32ImageType* m_Input;
Int32ImageType::Pointer m_Reference;
RAMDrivenAdaptativeStreamingManagerType::Pointer m_StreamingManager;
RasterizeFilterType::Pointer m_RasterizeReference;
};
}
......
......@@ -74,6 +74,8 @@ private:
// Doc example parameter settings
SetDocExampleParameterValue("il", "QB_1_ortho.tif");
SetDocExampleParameterValue("out", "EstimateImageStatisticsQB1.xml");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -72,6 +72,7 @@ private:
SetDocExampleParameterValue("outstats", "results.xml");
SetDocExampleParameterValue("feat", "perimeter");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -112,6 +112,8 @@ private:
SetDocExampleParameterValue("expr", "\"(b1 > 0.4)\"");
SetDocExampleParameterValue("field", "NONDVI");
SetDocExampleParameterValue("out", "PolylineFeatureFromImage_LI_NONDVI_gt.shp");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -180,6 +180,8 @@ private:
SetDocExampleParameterValue("maxnbit", "4");
SetDocExampleParameterValue("optobs", "true");
SetDocExampleParameterValue("out", "DSFuzzyModelEstimation.xml");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -169,6 +169,8 @@ private:
SetDocExampleParameterValue("nodatalabel","0");
SetDocExampleParameterValue("undecidedlabel","10");
SetDocExampleParameterValue("out","classification_fused.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -127,6 +127,8 @@ private:
SetDocExampleParameterValue("imstat", "EstimateImageStatisticsQB1.xml");
SetDocExampleParameterValue("model", "clsvmModelQB1.svm");
SetDocExampleParameterValue("out", "clLabeledImageQB1.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -220,6 +220,8 @@ private:
SetDocExampleParameterValue("maxit", "1000");
SetDocExampleParameterValue("ct", "0.0001");
SetDocExampleParameterValue("out", "ClassificationFilterOutput.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -182,6 +182,8 @@ private:
SetDocExampleParameterValue("out", "rates.csv");
SetDocExampleParameterValue("strategy", "smallest");
SetDocExampleParameterValue("mim","proportional");
SetOfficialDocLink();
}
void DoUpdateParameters()
......
......@@ -91,6 +91,7 @@ private:
SetDocExampleParameterValue("feat", "perimeter");
SetDocExampleParameterValue("cfield", "predicted");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -123,6 +123,8 @@ private:
SetDocExampleParameterValue("vec", "variousVectors.sqlite");
SetDocExampleParameterValue("field", "label");
SetDocExampleParameterValue("out","polygonStat.xml");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -178,6 +178,8 @@ private:
SetDocExampleParameterValue("imstat", "EstimateImageStatisticsQB1.xml");
SetDocExampleParameterValue("model", "clsvmModelQB1.svm");
SetDocExampleParameterValue("out", "clLabeledImageQB1.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -174,6 +174,8 @@ private:
SetDocExampleParameterValue("bi", "1.0");
SetDocExampleParameterValue("bf", "0.1");
SetDocExampleParameterValue("iv", "0");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -115,6 +115,8 @@ private:
SetDocExampleParameterValue("outfield.prefix.name","band_");
SetDocExampleParameterValue("field", "label");
SetDocExampleParameterValue("out","sample_values.sqlite");
SetOfficialDocLink();
}
void DoUpdateParameters()
......
......@@ -223,6 +223,8 @@ private:
SetDocExampleParameterValue("field", "label");
SetDocExampleParameterValue("instats","apTvClPolygonClassStatisticsOut.xml");
SetDocExampleParameterValue("out","resampledVectors.sqlite");
SetOfficialDocLink();
}
void DoUpdateParameters()
......
......@@ -82,6 +82,8 @@ public:
SetDocExampleParameterValue( "classifier.libsvm.opt", "false" );
SetDocExampleParameterValue( "io.out", "svmModelQB1.txt" );
SetDocExampleParameterValue( "io.confmatout", "svmConfusionMatrixQB1.csv" );
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -174,6 +174,8 @@ void DoInit() ITK_OVERRIDE
SetDocExampleParameterValue("io.out", "regression_model.txt");
SetDocExampleParameterValue("io.imstat", "training_statistics.xml");
SetDocExampleParameterValue("classifier", "libsvm");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -66,6 +66,8 @@ protected:
SetDocAuthors( "OTB Team" );
SetDocSeeAlso( " " );
SetOfficialDocLink();
Superclass::DoInit();
}
......
......@@ -145,6 +145,8 @@ private:
SetDocExampleParameterValue("out", "svmModel.svm");
SetDocExampleParameterValue("feat", "perimeter area width");
SetDocExampleParameterValue("cfield", "predicted");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......@@ -249,7 +251,7 @@ private:
ListSampleType::Pointer listSample = trainingShiftScaleFilter->GetOutput();
typename ConfidenceListSampleType::Pointer quality;
ConfidenceListSampleType::Pointer quality;
bool computeConfidenceMap(IsParameterEnabled("confmap") && m_Model->HasConfidenceIndex()
&& !m_Model->GetRegressionMode());
......
......@@ -103,6 +103,7 @@ private:
SetDocExampleParameterValue("descmod", "DSFuzzyModel.xml");
SetDocExampleParameterValue("out", "VectorDataDSValidation.shp");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -198,6 +198,8 @@ private:
SetDocExampleParameterValue("in2","sensor_stereo_right.tif");
SetDocExampleParameterValue("mode","full");
SetDocExampleParameterValue("out","homologous.txt");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -180,6 +180,8 @@ private:
SetDocExampleParameterValue("in", "cupriteSubHsi.tif");
SetDocExampleParameterValue("out", "FilterOutput.tif");
SetDocExampleParameterValue("method", "pca");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -169,6 +169,8 @@ private:
SetDocExampleParameterValue("in", "input.tif");
SetDocExampleParameterValue("mode.wavelet.form", "haar");
SetDocExampleParameterValue("out", "output_wavelet_haar.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -122,6 +122,8 @@ SetParameterDescription("out", "Output image containing the edge features.");
SetDocExampleParameterValue("in", "qb_RoadExtract.tif");
SetDocExampleParameterValue("channel", "1");
SetDocExampleParameterValue("out", "Edges.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -85,6 +85,8 @@ private:
// Doc example parameter settings
SetDocExampleParameterValue("in", "QB_Suburb.png");
SetDocExampleParameterValue("out", "LineSegmentDetection.shp");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -124,6 +124,8 @@ private:
SetDocExampleParameterValue("filter","lee");
SetDocExampleParameterValue("filter.lee.rad", "5");
SetDocExampleParameterValue("out", "despeckle.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -121,6 +121,8 @@ private:
SetDocExampleParameterValue("type.anidif.timestep", "0.1", exId);
SetDocExampleParameterValue("type.anidif.nbiter", "5", exId);
SetDocExampleParameterValue("type.anidif.conductance", "1.5", exId);
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -83,6 +83,7 @@ private:
SetDocExampleParameterValue("inxs", "QB_Toulouse_Ortho_XS.tif");
SetDocExampleParameterValue("out", "BundleToPerfectSensor.png uchar");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -135,6 +135,7 @@ private:
SetDocExampleParameterValue("inxs", "QB_Toulouse_Ortho_XS.tif");
SetDocExampleParameterValue("out", "Pansharpening.tif uint16");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -135,6 +135,8 @@ private:
SetDocExampleParameterValue("ie", "cupriteEndmembers.tif");
SetDocExampleParameterValue("out", "HyperspectralUnmixing.tif double");
SetDocExampleParameterValue("ua", "ucls");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -80,6 +80,8 @@ private:
SetDocExampleParameterValue("in", "cupriteSubHsi.tif");
SetDocExampleParameterValue("ne", "5");
SetDocExampleParameterValue("outendm", "VertexComponentAnalysis.tif double");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -393,6 +393,8 @@ private:
SetDocExampleParameterValue("method", "custom");
SetDocExampleParameterValue("method.custom.lut", "ROI_QB_MUL_1_SVN_CLASS_MULTI_PNG_ColorTable.txt");
SetDocExampleParameterValue("out", "Colorized_ROI_QB_MUL_1_SVN_CLASS_MULTI.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -130,6 +130,8 @@ private:
SetDocExampleParameterValue("roi.starty", "30");
SetDocExampleParameterValue("roi.sizex", "150");
SetDocExampleParameterValue("roi.sizey", "200");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -85,6 +85,8 @@ private:
// Doc example parameter settings
SetDocExampleParameterValue("il", "GomaAvant.png GomaApres.png");
SetDocExampleParameterValue("out", "otbConcatenateImages.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -138,6 +138,8 @@ private:
SetDocExampleParameterValue("in", "QB_Toulouse_Ortho_XS.tif");
SetDocExampleParameterValue("out", "otbConvertWithScalingOutput.png uint8");
SetDocExampleParameterValue("type", "linear");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -71,6 +71,8 @@ private:
// Doc example parameter settings
SetDocExampleParameterValue("in", "QB_Toulouse_Ortho_Elev.tif");
SetDocExampleParameterValue("out", "outputDEM");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -133,6 +133,7 @@ private:
SetDocExampleParameterValue("mode", "list");
SetDocExampleParameterValue("mode.list.indir", "/home/user/srtm_dir/");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......
......@@ -117,6 +117,8 @@ private:
SetDocExampleParameterValue("sizex", "150");
SetDocExampleParameterValue("sizey", "150");
SetDocExampleParameterValue("out", "ExtractROI.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() ITK_OVERRIDE
......