Classification OTB applications

From OTBWiki
Revision as of 15:22, 27 May 2013 by Cpeyrega (Talk | contribs)

Jump to: navigation, search

A new classification framework has been made available for OTB applications since OTB 3.18. It is based on the Machine Learning framework of OpenCV.

For those who used the former OTB classification framework, exclusively based on the SVM method (within the libSVM library), some modifications should be considered.

Why?

This brings the following benefits

  • a generic classification application with choosable classifiers
  • additional independent classifiers
  • easier to add new classifiers
  • easier to maintain the existing classifiers

What?

The main modification concerns the addition of new classifiers implemented within the OpenCV library such as

  • libSVM (the original OTB implementation is still available) (-classifier libsvm)
  • SVM classifier (by OpenCV) (-classifier svm)
  • Boosting classifier (-classifier boost)
  • Decision Tree classifier (-classifier dt)
  • Gradient Boosted Tree classifer (-classifier gbt)
  • Artificial Neural Network classifier (-classifier ann)
  • Normal Bayes classifier (-classifier bayes)
  • Random Forests classifier (-classifier rf)
  • KNN classifier (-classifier knn)


In order to handle these additional classifiers within the generic classification applications the following applications were removed:

  • TrainSVMImagesClassifier, replaced by TrainImagesClassifier
  • ImageSVMClassifier, replaced by ImageClassifier
  • ValidateSVMImagesClassifier, NOT replaced because its use is redundant with the ComputeConfusionMatrix application
  • ValidateImagesClassifier, removed because its use is redundant with the ComputeConfusionMatrix application

How?

Here are examples of how to use the new classes:

Training with the former libSVM based OTB framework

Replace the old command line:

otbcli_TrainSVMImagesClassifier
 -io.il input_training_multichannel_image_1.tif input_training_multichannel_image_2.tif input_training_multichannel_image_3.tif 
 -io.vd input_training_vector_data_1.shp input_training_vector_data_2.shp input_training_vector_data_3.shp 
 -io.imstat output_training_statistics_file.xml
 -svm.opt true
 -io.out output_SVM_model.svm
 -rand 121212

by the equivalent new command line:

otbcli_TrainImagesClassifier
 -io.il input_training_multichannel_image_1.tif input_training_multichannel_image_2.tif input_training_multichannel_image_3.tif 
 -io.vd input_training_vector_data_1.shp input_training_vector_data_2.shp input_training_vector_data_3.shp 
 -io.imstat output_training_statistics_file.xml
 -classifier libsvm
 -classifier.libsvm.opt true
 -io.out output_SVM_model.svm
 -rand 121212

The new -classifier parameter let the user choose other classification methods (available values are: libsvm, svm, boost, dt, gbt, ann, bayes, rf, knn) with their specific additional parameters.


Classification

Replace the old command line:

otbcli_ImageSVMClassifier
 -in input_multichannel_image_to_classify.tif 
 -imstat input_training_statistics_file.xml
 -svm input_SVM_model.svm
 -out output_monochannel_classified_image.tif

by the equivalent new command line:

otbcli_ImageClassifier
 -in input_multichannel_image_to_classify.tif 
 -imstat input_training_statistics_file.xml
 -model input_SVM_model.svm
 -out output_monochannel_classified_image.tif


Model validation

As explained before, both applications ValidateSVMImagesClassifier and ValidateImagesClassifier were removed because they are redundant with the ComputeConfusionMatrix application which is recommanded to proceed a model validation.

However, both ValidateSVMImagesClassifier and ComputeConfusionMatrix applications are not strictly speaking equivalent, since they do not have the same API interfaces.