Superpixel based SNIC Implementation for image segmentation and boundary delineation. This is a wrapper for Simple Non-Iterative Clustering algorithm. Use this for segementing different areas of image in unsupervised manner, based on spectral differences
-
Rasterio object is required for geo-referencing of the output. Just pass in
rasterio.open()
here -
Also known as
number of segments
in your image. Larger values give more closed polygons, there is no optimal value. Eg: If you give100
, it will try to create 100 closed polygons -
Specify the filename/full path where you want to output the geojson file
-
- File Name
- GeoJson File
Superpixel: An un-supervised algorithm that works by planting "seeds" across the image, which is required as an input. The idea is to cluster areas by pixel similarity of neighbors of the seeds. Can be very sensitive to pixel changes. The seed values is directly proportional to the number of areas to segment.
- High seed values will give you more number of closed polygons
- High compactness values will give more uniform boundaries, more squared, but will pick up less variations
pip install git+https://github.com/purijs/Sentinel-Training-Data-Generation.git
gdal >= 3.1
Input image should have at least 12 Bands (Sentinel - 2A)
from training.unsupervised.segmentation import Segmentation
import rasterio
obj = Segmentation(rasterio.open('data/myimage.tif'), 400, 'sample.geojson')
obj.exportGeoJsonFile()
Check out the example file [here]
Download sample sentinel file here