Region Growing Segmentation

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
(Model Description)
Line 2: Line 2:
 
Different QGIS geoalgorithms are implemented in order to segment a greyscale single-band Canopy Height Model (CHM) raster using a Region Growing approach. These are the steps you need to follow to use the Image Segmentation Model. The following procedure is explained using QGIS version 2.12.2.
 
Different QGIS geoalgorithms are implemented in order to segment a greyscale single-band Canopy Height Model (CHM) raster using a Region Growing approach. These are the steps you need to follow to use the Image Segmentation Model. The following procedure is explained using QGIS version 2.12.2.
 
# Download the *.model file.
 
# Download the *.model file.
# Open QGIS and go to the Processing Toolbox; if the Toolbox is not opened go to {{button|text=Processing}} {{button|text=Toolbox}} to activate it. Once the Toolbox is opened go to {{button|text=Models}} {{button|text=Tools}} {{button|text=Add model from file}} and load the previously downloaded model.  
+
# Open QGIS and go to the Processing Toolbox; if the Toolbox is not opened go to {{mitem|text= Processing → Toolbox}} to activate it. Once the Toolbox is opened go to {{mitem|text= Models → Tools → Add model from file}} and load the previously downloaded model.  
 
# The model should appear in the Models tab. Double click on it to execute.
 
# The model should appear in the Models tab. Double click on it to execute.
 
# A window showing the different inputs and outputs should appear, just as if you were using any other geoalgorithm.  
 
# A window showing the different inputs and outputs should appear, just as if you were using any other geoalgorithm.  
 
# You will need to provide the model with the CHM and a polygon shapefile containing the boundary of the plot that you want to segment.
 
# You will need to provide the model with the CHM and a polygon shapefile containing the boundary of the plot that you want to segment.
# The main output is called “Segments_noGaps”, you can disable the rest since they are only used when creating the Model to check if every step is working properly.
+
# The main output is called ''Segments_noGaps'', you can disable the rest since they are only used when creating the Model to check if every step is working properly.
 
# If any error window from Python pops up close it and the model will continue running properly. This error windows should not imply any error on the results of the model.
 
# If any error window from Python pops up close it and the model will continue running properly. This error windows should not imply any error on the results of the model.
  
Line 12: Line 12:
 
To access the Model script right click on it and select Edit model. Here are the steps followed in the model in order to obtain the final segmentation.
 
To access the Model script right click on it and select Edit model. Here are the steps followed in the model in order to obtain the final segmentation.
 
# Starting from the CHM, SAGA’s Seed generation geoalgorithm is performed three times changing the ''Bandwith'' parameter each time. A big bandwidth value will be used for extracting big crowns, the lowest value has been used to extract the seeds belonging to small crowns and the intermediate value for the places where there should be no crowns (gaps). These values can be changed for optimizing the model to the current CHM.
 
# Starting from the CHM, SAGA’s Seed generation geoalgorithm is performed three times changing the ''Bandwith'' parameter each time. A big bandwidth value will be used for extracting big crowns, the lowest value has been used to extract the seeds belonging to small crowns and the intermediate value for the places where there should be no crowns (gaps). These values can be changed for optimizing the model to the current CHM.
# The seeds in point shapfile format generated for the gaps have to be filtered using the QGIS geoalgorithm {{mitem|text= Extract by attribute}}, applying a height threshold in order to keep just the seeds related to those places without tree crowns, e.g. those with a height value lower than 5 meters.
+
# The seeds in point shapfile format generated for the gaps have to be filtered using the QGIS geoalgorithm {{button|text=Extract by attribute}}, applying a height threshold in order to keep just the seeds related to those places without tree crowns, e.g. those with a height value lower than 5 meters.
# To avoid over-segmentation, a buffer around the seeds obtained for the large crowns has to be carried out using the QGIS geoalgorithm {{mitem|text= Fixed distance buffer}}. Afterwards, this buffer will be used to filter the points from the small crowns seeds, keeping only those points outside of the buffer. For this purpose, QGIS geoalgorithm {{mitem|text= Difference}} was used.
+
# To avoid over-segmentation, a buffer around the seeds obtained for the large crowns has to be carried out using the QGIS geoalgorithm {{button|text=Fixed distance buffer}}. Afterwards, this buffer will be used to filter the points from the small crowns seeds, keeping only those points outside of the buffer. For this purpose, QGIS geoalgorithm {{button|text=Difference}} was used.
 
# SAGA’s geoalgorithm {{mitem|text= Merge layer}} is used for merging all the final seed shapefiles.
 
# SAGA’s geoalgorithm {{mitem|text= Merge layer}} is used for merging all the final seed shapefiles.
# Merged seeds are rasterized using GDAL’s function {{mitem|text= Rasterize (vector to raster)}}. The resolution of the output raster has to match the CHM’s resolution. In this case, the resolution is set to 0.25x0.25.
+
# Merged seeds are rasterized using GDAL’s function {{button|text=Rasterize (vector to raster)}}. The resolution of the output raster has to match the CHM’s resolution. In this case, the resolution is set to 0.25x0.25.
# The CHM and the rasterized seeds have to be clipped by the extent of the plot’s boundary (*.shp) using {{mitem|text= Clip raster by mask layer}} from GDAL.
+
# The CHM and the rasterized seeds have to be clipped by the extent of the plot’s boundary (*.shp) using {{button|text=Clip raster by mask layer}} from GDAL.
# SAGA’s {{mitem|text= Simple region growing}} is performed using the previous clipped raster files as inputs. All the parameters are set as default, except for the “Threshold – Similarity” which is set at 0.0001 in order to cover the entire plot with the regions.
+
# SAGA’s {{button|text=Simple region growing}} is performed using the previous clipped raster files as inputs. All the parameters are set as default, except for the “Threshold – Similarity” which is set at 0.0001 in order to cover the entire plot with the regions.
 
# Parallel to this step, a mask for the gaps is created for later on clipping the gaps out of the segments.  
 
# Parallel to this step, a mask for the gaps is created for later on clipping the gaps out of the segments.  
#* Using the {{mitem|text= Raster calculator}} from GDAL with the CHM as input (“Input layer A”). The condition set is “A<5” so that the calculator returns a raster where, if the condition is true a value of 1 is assigned, and if not, a 0.
+
#* Using the {{button|text=Raster calculator}} from GDAL with the CHM as input (“Input layer A”). The condition set is “A<5” so that the calculator returns a raster where, if the condition is true a value of 1 is assigned, and if not, a 0.
#* Afterwards, the generated raster is polygonized and the mask is generated by extracting the polygons with a value of 0 in the attribute table by using QGIS geoalgorithm {{mitem|text= Extract by attribute}}.
+
#* Afterwards, the generated raster is polygonized and the mask is generated by extracting the polygons with a value of 0 in the attribute table by using QGIS geoalgorithm {{button|text=Extract by attribute}}.
# Finally, the segments generated in the simple region growing are clipped with the gaps mask using {{mitem|text= Clip raster by mask layer}} from GDAL. This raster is clipped again with the boundary of the plot for being able to run “Hoover metrics” if necessary.
+
# Finally, the segments generated in the simple region growing are clipped with the gaps mask using {{button|text=Clip raster by mask layer}} from GDAL. This raster is clipped again with the boundary of the plot for being able to run “Hoover metrics” if necessary.

Revision as of 16:54, 17 June 2016

QGIS Individual Tree Crown Segmentation Method

Different QGIS geoalgorithms are implemented in order to segment a greyscale single-band Canopy Height Model (CHM) raster using a Region Growing approach. These are the steps you need to follow to use the Image Segmentation Model. The following procedure is explained using QGIS version 2.12.2.

  1. Download the *.model file.
  2. Open QGIS and go to the Processing Toolbox; if the Toolbox is not opened go to Processing → Toolbox to activate it. Once the Toolbox is opened go to Models → Tools → Add model from file and load the previously downloaded model.
  3. The model should appear in the Models tab. Double click on it to execute.
  4. A window showing the different inputs and outputs should appear, just as if you were using any other geoalgorithm.
  5. You will need to provide the model with the CHM and a polygon shapefile containing the boundary of the plot that you want to segment.
  6. The main output is called Segments_noGaps, you can disable the rest since they are only used when creating the Model to check if every step is working properly.
  7. If any error window from Python pops up close it and the model will continue running properly. This error windows should not imply any error on the results of the model.

Model Description

To access the Model script right click on it and select Edit model. Here are the steps followed in the model in order to obtain the final segmentation.

  1. Starting from the CHM, SAGA’s Seed generation geoalgorithm is performed three times changing the Bandwith parameter each time. A big bandwidth value will be used for extracting big crowns, the lowest value has been used to extract the seeds belonging to small crowns and the intermediate value for the places where there should be no crowns (gaps). These values can be changed for optimizing the model to the current CHM.
  2. The seeds in point shapfile format generated for the gaps have to be filtered using the QGIS geoalgorithm Extract by attribute, applying a height threshold in order to keep just the seeds related to those places without tree crowns, e.g. those with a height value lower than 5 meters.
  3. To avoid over-segmentation, a buffer around the seeds obtained for the large crowns has to be carried out using the QGIS geoalgorithm Fixed distance buffer. Afterwards, this buffer will be used to filter the points from the small crowns seeds, keeping only those points outside of the buffer. For this purpose, QGIS geoalgorithm Difference was used.
  4. SAGA’s geoalgorithm Merge layer is used for merging all the final seed shapefiles.
  5. Merged seeds are rasterized using GDAL’s function Rasterize (vector to raster). The resolution of the output raster has to match the CHM’s resolution. In this case, the resolution is set to 0.25x0.25.
  6. The CHM and the rasterized seeds have to be clipped by the extent of the plot’s boundary (*.shp) using Clip raster by mask layer from GDAL.
  7. SAGA’s Simple region growing is performed using the previous clipped raster files as inputs. All the parameters are set as default, except for the “Threshold – Similarity” which is set at 0.0001 in order to cover the entire plot with the regions.
  8. Parallel to this step, a mask for the gaps is created for later on clipping the gaps out of the segments.
    • Using the Raster calculator from GDAL with the CHM as input (“Input layer A”). The condition set is “A<5” so that the calculator returns a raster where, if the condition is true a value of 1 is assigned, and if not, a 0.
    • Afterwards, the generated raster is polygonized and the mask is generated by extracting the polygons with a value of 0 in the attribute table by using QGIS geoalgorithm Extract by attribute.
  9. Finally, the segments generated in the simple region growing are clipped with the gaps mask using Clip raster by mask layer from GDAL. This raster is clipped again with the boundary of the plot for being able to run “Hoover metrics” if necessary.
Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export