Region Growing Segmentation
From AWF-Wiki
(Difference between revisions)
(→QGIS Individual Tree Crown Segmentation Method) |
|||
Line 5: | Line 5: | ||
# 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 [[:File:HEW07 chm proy.tif|CHM (download here)]] and a [[:File:HEW07 Corrected Bound.zip | + | # You will need to provide the model with the [[:File:HEW07 chm proy.tif|CHM (download here)]] and a [[:File:HEW07 Corrected Bound.zip|polygon shapefile (download here)]] 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. |
Revision as of 12:58, 12 July 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.
- Download the *.model file (extract .zip after download).
- 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.
- 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.
- You will need to provide the model with the CHM (download here) and a polygon shapefile (download here) 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.
- 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.
- 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.
- Note: The Seed Generation parameters can be modified according to the type of forest under study. The exmple here described has been adjusted to a broadleaved forest with a high tree crown cover.
- 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.
- 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.
- SAGA’s geoalgorithm Merge layer is used for merging all the final seed shapefiles.
- 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.
- 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.
- 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.
- 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.
- 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.