Object-based classification (Tutorial)

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
= Mean-shift segmentation of large size images =
 
= Mean-shift segmentation of large size images =
* Perform a mean shift filtering on the input image ''Subset_S2A_MSIL2A_20170619T_BOA.tif''. We extract homogeneous objects on the basis of a filtered image.
+
* Type into the search box of the Windows taskbar: {{typed|text=mapla.bat}}. Click on mapla.bat to open  Monteverdi Application Launcher.
Go to {{mitem|text=Processing-Toolbox --> Orfeo Toolbox (image analysis) --> Image Filtering --> Exact Large-Scale Mean-Shift segmentation, step 1 (Smoothing)}}.  
+
* In the search engine of mapla, type {{typed|text=Meanshift}} and double click '''LargeScaleMeanshift'''.
##* Set the ''Subset_S2A_MSIL2A_20170619T_BOA'' layer as {{button|text=Input image}}.
+
* Select the input image: '''Subset_S2A_MSIL2A_20170619T_MUL.tif ''' (datatype uint 16bits).
##* Increase the ''Available RAM (Mb)'' according to your system to speed up the process.
+
* The {{button|text=Range radius}} value can be set to {{typed|text=600}}. The optimal value depends on datatype dynamic range of the input image and requires experimental trials for the specific classifcation objectives.
##* The {{button|text=Range radius}} should be set to 30.
+
* The value for {{button|text=Minimum Segment size}} (in pixels) can be set to {{typed|text=10}}. It depends on the size of the minimum mapping unit and the smallest object that can be destinguished.
##* Leave all other configurations as they are and click {{button|text=Run}}. Have a look on the resulting filtered and spatial images.
+
* Leave all other configurations as they are and click {{button|text=Run}}. Have a look on the resulting filtered and spatial images.
# Step. Convert the filtered image to one band image object. Go to {{mitem|text=Processing-Toolbox --> Orfeo Toolbox (image analysis) --> Segmentation --> Exact Large-Scale Mean-Shift segmentation, step 2}}.  
+
* The Output GIS vector file is specified as a shapefile with the extension *.shp.
##* The ''Filtered image'' is {{button|text=Filter output}} from step 1.
+
* Click {{button|text=Execute}}.
##* Leave the ''Spatial image'' as {{button|text= [not selected]}}.
+
[[File:qgis_otb_LargeScaleMeanshift.png|500px]]
##* {{button|text=Range radius}} is set to 30.
+
* Evaluate the segmentation results:
##* Define a path to the '''Directory where to write temporary files'''.
+
Load the output vector file into QGIS on top of the image ''Subset_S2A_MSIL2A_20170619T_Mul.tif''
##* Leave all other configurations as they are and click {{button|text=Run}}. The Output image is a labeled image where neighbor pixels whose range distance is below range radius will be grouped together into the same cluster.
+
Mark the vector layer in the Qgis Layers window. {{mitem|text=Layer --> Properties --> Symbology  --> Simple Fill}} to ''No Brush'' and {{mitem|text=Stroke color}} to white.
# Step. Adjust the image object size merging small regions with the module {{mitem|text=Processing-Orfeo Toolbox (image analysis) --> Segmentation-Exact --> Large-Scale Mean-Shift segmentation, step 3 (optional)}}.
+
##* The ''Input image'' is the {{button|text=''Subset_S2A_MSIL2A_20170619T_BOA''}} layer.
+
##* The ''Segmented image'' is {{button|text=Output image}} from step 2.
+
##* The {{button|text=Minimum Region size}} is set to 10.
+
##* Leave all other configurations as they are and click {{button|text=Run}}.
+
# Step. Convert the image segments from raster to polygon vectors. Label ID, mean and standard deviation, number of the pixels in an image polygon are calculated and added as additional columns in the resulting shapefile.{{mitem|text=Processing-Orfeo Toolbox (image analysis) --> Segmentation-Exact Large-Scale Mean-Shift segmentation, step 4}}
+
##* The ''Input image'' is the {{button|text=Subset_S2A_MSIL2A_20170619T_BOA}} layer.
+
##* ''Segmented image'' is  {{button|text=Output image}} from step 3.
+
##* The name of ''Output GIS vector file'' is {{button|text=seg_Subset_S2A_MSIL2A_20170619T_BOA.shp}}
+
##* For the rest of parameters keep default values.{{button|text=Run}}.
+
Change {{mitem|text=Layer --> Properties Style --> Fill Style}} to ''No Brush'' and {{mitem|text=Colors --> Border}} to white. Overlay the vector file on top of the image ''Subset_S2A_MSIL2A_20170619T_BOA.tif'' to evaluate the segmentation result.
+
  
== Preparation of reference data ==
+
= Preparation of reference data =
 
Join the Land use/cover (LUC) class attribute of manually digitized training areas with the image segments. {{mitem|text=Vector  --> Data Management Tools --> Join Attributes by Location ...}}.
 
Join the Land use/cover (LUC) class attribute of manually digitized training areas with the image segments. {{mitem|text=Vector  --> Data Management Tools --> Join Attributes by Location ...}}.
 
##* The ''Target vector file'' is the {{button|text=Output GIS vector file}} of step 4.
 
##* The ''Target vector file'' is the {{button|text=Output GIS vector file}} of step 4.

Revision as of 13:46, 10 December 2018

Mean-shift segmentation of large size images

  • Type into the search box of the Windows taskbar: mapla.bat. Click on mapla.bat to open Monteverdi Application Launcher.
  • In the search engine of mapla, type Meanshift and double click LargeScaleMeanshift.
  • Select the input image: Subset_S2A_MSIL2A_20170619T_MUL.tif (datatype uint 16bits).
  • The Range radius value can be set to 600. The optimal value depends on datatype dynamic range of the input image and requires experimental trials for the specific classifcation objectives.
  • The value for Minimum Segment size (in pixels) can be set to 10. It depends on the size of the minimum mapping unit and the smallest object that can be destinguished.
  • Leave all other configurations as they are and click Run. Have a look on the resulting filtered and spatial images.
  • The Output GIS vector file is specified as a shapefile with the extension *.shp.
  • Click Execute.

Qgis otb LargeScaleMeanshift.png

  • Evaluate the segmentation results:

Load the output vector file into QGIS on top of the image Subset_S2A_MSIL2A_20170619T_Mul.tif Mark the vector layer in the Qgis Layers window. Layer --> Properties --> Symbology --> Simple Fill to No Brush and Stroke color to white.

Preparation of reference data

Join the Land use/cover (LUC) class attribute of manually digitized training areas with the image segments. Vector --> Data Management Tools --> Join Attributes by Location ....

      • The Target vector file is the Output GIS vector file of step 4.
      • Join vector layer is training_manual_poly.shp.
      • Output vector seg_Subset_S2A_MSIL2A_20170619T_BOA_train.shp.
      • For the rest of parameters keep default values.OK.

Rename the field names of the resulting output vector attribut table avoiding upper capitals and underline using the Table Manager plugin. Rename the attribut field C_ID to class.

Object-based classifcation using SVM algorithm

We may use the windows command line and OTB QT graphical user interfaces. Start --> All Programs --> OSGeo4W --> OSGeo4W Shell or double click on the file C:\OSGeo4W64\OSGeo4W.bat.

  1. A windows command shell opens, please type otbgui_ComputeOGRLayersFeaturesStatistics.
      • Name of the input vector is seg_Subset_S2A_MSIL2A_20170619T_BOA_train.shp.
      • XML file containing mean and variance of each feature is seg_Subset_S2A_MSIL2A_20170619T_BOA_train.xml.
      • In the List of features to consider for statistics mark the columns meanB0, meanB1, meanB2.Execute. Calculate also an XML file for vector file seg_Subset_S2A_MSIL2A_20170619T_BOA.shp.
  2. Type into the OSGeo4W shell otbgui_TrainOGRLayersClassifier.
      • Name of the input shapefile is seg_Subset_S2A_MSIL2A_20170619T_BOA_train.shp.
      • XML file containing mean and variance of each feature is seg_Subset_S2A_MSIL2A_20170619T_BOA_train.xml.
      • Output model filename is seg_Subset_S2A_MSIL2A_20170619T_BOA_train.model
      • In the List of features to consider for statistics mark the columns meanB0, meanB1, meanB2, ...
      • The name ofField containing the class id for supervision" is class.Execute.
  3. Type into the OSGeo4W shell otbgui_OGRLayerClassifier.
      • Name of the input shapefile is seg_Subset_S2A_MSIL2A_20170619T_BOA.shp.
      • XML file containing mean and variance of each feature is seg_Subset_S2A_MSIL2A_20170619T_BOA.xml.
      • Input model filename is seg_Subset_S2A_MSIL2A_20170619T_BOA_train.model
      • In the List of features to consider for statistics mark the columns meanB0, meanB1, meanB2, ...
      • The name ofField containing the predicted class" is predicted.Execute.
  4. Open the resulting vector file in a QGIS map view.
      • Change the style of the classified vector layer: Go to layer properties --> style. Click on ‘Load Style’. Browse for OBIA_legend file and select OBIA_legend.qml}}. apply, OK.
  5. Simplify the vector file using Vector --> Geoprocessing Tools --> Dissolve...
      • Input vector layer is seg_Subset_S2A_MSIL2A_20170619T_BOA.shp.
      • Dissolve field is predicted.
      • Output shapefile is seg_188_Subset_S2A_MSIL2A_20170619T_BOA_diss.shp



info.png Info
For more detailed information on the SVM algorithm visit the library website
Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export