{"id":163,"date":"2019-03-15T21:39:52","date_gmt":"2019-03-15T21:39:52","guid":{"rendered":"https:\/\/rossedwards.co.uk\/blog\/?p=163"},"modified":"2019-08-24T17:52:29","modified_gmt":"2019-08-24T17:52:29","slug":"assisted-classification-with-orfeo-toolbox-otb","status":"publish","type":"post","link":"https:\/\/rossedwards.co.uk\/blog\/2019\/03\/15\/assisted-classification-with-orfeo-toolbox-otb\/","title":{"rendered":"Supervised &#038; unsupervised classification with Orfeo ToolBox (OTB)"},"content":{"rendered":"\n<p>Having discovered <a href=\"https:\/\/www.orfeo-toolbox.org\/\">Orfeo ToolBox<\/a> and it&#8217;s very handy <a href=\"https:\/\/gitlab.orfeo-toolbox.org\/orfeotoolbox\/qgis-otb-plugin\/blob\/master\/README.md\">QGIS plugin<\/a>, I set about reviewing each of OTB&#8217;s supervised classifiers, to see which one performs the best with the goal of generating a perfect surface mask that I can use in my terrain project within RV4 engine. <\/p>\n\n\n\n<p>Example showing source raster + <strong>libsvm_linear<\/strong> classifier:<\/p>\n\n\n<p><iframe loading=\"lazy\" frameborder=\"0\" class=\"juxtapose\" width=\"100%\" height=\"740\" src=\"https:\/\/cdn.knightlab.com\/libs\/juxtapose\/latest\/embed\/index.html?uid=56fa083a-c697-11e9-b9b8-0edaf8f81e27\"><\/iframe><\/p>\n\n\n\n<!--more-->\n\n\n\n<p><br>Example showing source raster + <strong>libsvm_rbf<\/strong> classifier: <\/p>\n\n\n<p><iframe loading=\"lazy\" frameborder=\"0\" class=\"juxtapose\" width=\"100%\" height=\"740\" src=\"https:\/\/cdn.knightlab.com\/libs\/juxtapose\/latest\/embed\/index.html?uid=7bbb3338-c697-11e9-b9b8-0edaf8f81e27\"><\/iframe><\/p>\n\n\n\n<p><br>Example showing source raster + <strong>Artificial Neural Network<\/strong> classifier: <\/p>\n\n\n<p><iframe loading=\"lazy\" frameborder=\"0\" class=\"juxtapose\" width=\"100%\" height=\"740\" src=\"https:\/\/cdn.knightlab.com\/libs\/juxtapose\/latest\/embed\/index.html?uid=c1c27710-c697-11e9-b9b8-0edaf8f81e27\"><\/iframe><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Complete list of machine learning <a href=\"https:\/\/www.orfeo-toolbox.org\/CookBook\/Applications\/app_TrainImagesClassifier.html#example\">classifiers<\/a> tested:<br><strong>libsvm_linear <\/strong>&#8211; (Support Vector Machines)<strong><br>libsvm_rbf <br>libsvm_poly<br>libsvm_sigmoid <br>boost_discrete <\/strong> &#8211; (OpenCV)<strong><br>boost_real<\/strong>  <strong><br>boost_logit<br>boost_gentle<br>dt <\/strong>&#8211;<strong> <\/strong>(Decision Tree &#8211; OpenCV)<strong><br>ann <\/strong>&#8211;<strong> <\/strong>(Artificial Neural Network &#8211; OpenCV)<strong><br>bayes <\/strong>&#8211; (Normal Bayes &#8211; OpenCV)<strong><br>rf <\/strong>&#8211; (Random Forests &#8211; OpenCV)<strong><br>knn <\/strong>&#8211; (K-Nearest Neighbors &#8211; OpenCV)<strong><br>sharkrf  <\/strong>&#8211; (Random Forests classifier based on Shark)<strong><br>sharkkm&nbsp;<\/strong>&#8211;&nbsp;(KMeans unsupervised classifier based on Shark)<\/p>\n\n\n\n<p><strong>Results of the supervised classifiers:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.rossedwards.co.uk\/arma\/QGIS\/stats.PNG\" alt=\"\"\/><\/figure>\n\n\n\n<p>Those in red were not able to generate matching number of classes as listed within Vector Data List (ROI&#8217;s).<\/p>\n\n\n\n<p>These are the steps in sequence needed to create any of the above classifications:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.rossedwards.co.uk\/arma\/QGIS\/otb.PNG\" alt=\"\"\/><\/figure>\n\n\n\n<p>I then tested an unsupervised classification using the <strong>K-means<\/strong> classifier<br><\/p>\n\n\n\n<p>Example showing the result of <strong>K-means<\/strong> classification + tidied up version:<\/p>\n\n\n<p><iframe loading=\"lazy\" frameborder=\"0\" class=\"juxtapose\" width=\"100%\" height=\"740\" src=\"https:\/\/cdn.knightlab.com\/libs\/juxtapose\/latest\/embed\/index.html?uid=f4c65f96-c697-11e9-b9b8-0edaf8f81e27\"><\/iframe><\/p>\n\n\n\n<p><br>In the above example I set the K-means classes &#8216;K&#8217; to 12. I carried out 2 initial merges of classes using the <strong>GRASS<\/strong> process &#8216;<strong><a href=\"https:\/\/grass.osgeo.org\/grass70\/manuals\/r.reclass.html\">r.reclass<\/a><\/strong>&#8216;, further merges were made by hand within attributes of classes in the layer properties. ironically given this was an unsupervised classifier it actually took more manual input than the supervised classifiers. Forest seemed to be picked out fairly well, however road and building details were lost to merging. <\/p>\n\n\n\n<p>A useful reference article with overview of key machine learning algorithms:<br><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2017\/09\/common-machine-learning-algorithms\/\">https:\/\/www.analyticsvidhya.com\/blog\/2017\/09\/common-machine-learning-algorithms\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having discovered Orfeo ToolBox and it&#8217;s very handy QGIS plugin, I set about reviewing each of OTB&#8217;s supervised classifiers, to see which one performs the best with the goal of generating a perfect surface mask that I can use in my terrain project within RV4 engine. Example showing source raster + libsvm_linear classifier:<\/p>\n","protected":false},"author":1,"featured_media":245,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,2,4],"tags":[],"_links":{"self":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts\/163"}],"collection":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":55,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":1135,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/posts\/163\/revisions\/1135"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/media\/245"}],"wp:attachment":[{"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rossedwards.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}