Image segmentation

From Open Foris Wiki

Jump to: navigation, search

This tutorial provides an example of hierarchical segmentation of a resized Landsat image for object based analysis.

Exercise:

cd /home/...

1. For this exercise we cut a subset of the input image landsat_t1.tif for the classification to reduce computation time:

gdal_translate -srcwin 1000 1000 500 500 landsat-t1.tif subset.tif

2. Create initial segments using oft-seg

oft-seg subset.tif seg_min50.tif

Provide 0 for NODATA value, minimum segment size of 50 pixels and 0 for min and max distance questions as well as for the size weighting questions.

Please give NODATA value: 0
Using NoData value 0.000000
Min. segment size?:50
Min. spec. dist. btw segs?:0
Max. spec. dist. btw segs?:0
Use size weighting?:0
3. Compute segment average image to look how well it worked
 oft-avg -ot Byte  seg_min50.tif subset.tif  avg_subset.tif

4. Now, use the initial segmentation as a base and run a hierarchical segmentation with 10 pixel increase in the size after each iteration. This may take some time.

hier_seg.bash subset.tif seg_min50.tif 60 100 10 0

5. The resulting files, are called n_seg_min50.tif, where n=60,70,80,90,100

6. To vectorize the segmentation output, you can use, where for n_seg_min50.tif you have to choose the eg 60_seg_min50.tif

gdal_polygonize.py 60_seg_min50.tif -f "ESRI Shapefile" out.shp

7. Finally, you can visualize the segment borders in QGis or other GIS software.

Output of image segmentation:60_seg_min50.tif

Back to Open Foris Toolkit Main Page

Back to Tools & Exercises



Personal tools