GRASS logo


i.segment.uspo - Unsupervised segmentation parameter optimization


imagery, variance, segmentation, threshold


i.segment.uspo --help
i.segment.uspo [-knha] group=name [maps=name[,name,...]] output=name [segment_map=name] regions=name[,name,...] segmentation_method=string [thresholds=float[,float,...]] [threshold_start=float] [threshold_stop=float] [threshold_step=float] [minsizes=integer[,integer,...]] [minsize_start=integer] [minsize_stop=integer] [minsize_step=integer] [radiuses=float[,float,...]] [radius_start=float] [radius_stop=float] [radius_step=float] [hrs=float[,float,...]] [hr_start=float] [hr_stop=float] [hr_step=float] [autocorrelation_indicator=string] [optimization_function=string] [f_function_alpha=float] [number_best=integer] [memory=integer] [processes=integer] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Keep all segmented maps
Non-hierarchical segmentation (DEPRECATED: This is now the default setting)
Use hierarchical segmentation
Use adaptive spectral bandwidth (with mean shift)
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


group=name [required]
Group to use for segmentation
Raster band(s) for which to calculate variance (default: all group members)
output=name [required]
Name for output file (- for standard output)
Prefix for "best" output segmentation map per region
regions=name[,name,...] [required]
Regions in which to analyze the variance
segmentation_method=string [required]
Segmentation method to use
Options: region_growing, mean_shift
Default: region_growing
Thresholds to test
Lowest threshold to test
Threshold at which to stop (not included)
Step to use between thresholds
Minimum number of cells in a segment to test
Lowest minimum segment size to test
Value for minimum segment size at which to stop (not included)
Step to use between minimum segment sizes
Radiuses to test
Lowest radius to test
Radius at which to stop (not included)
Step to use between radiuses
Spectral bandwidths to test
Lowest spectral bandwith to test
Spectral bandwith at which to stop (not included)
Step to use between spectral bandwidths
Indicator for measuring inter-segment heterogeneity
Options: morans, geary
Default: morans
Optimization function used to determine "best" parameters
Options: sum, f
Default: sum
Alpha value used for F-measure optimization function
Default: 1
Number of desired best parameter values and maps
Default: 1
Total memory (in MB) to allocate (will be divided by processes)
Default: 300
Number of processes to run in parallel
Default: 1

Table of contents


i.segment.uspo provides unsupervised segmentation parameter optimization for i.segment. It runs segmentation across a user defined set of thresholds and minimum segment sizes, as well, for the mean shift algorithm, a set of spectral and spatial bandwiths. For the mean shift algorithm, you can also activate adaptive bandwidth using the -a flag.

The module then selects the parameters providing the highest values of a given optimization function. The number of "best" parameter combinations to provide to the user per region is defined by number_best.

The user provides an imagery group and the name of an output text file where parameter and optimization values for all tested segmentations are stored. The user can either give a list of thresholds and minimum sizes, or provides start, stop and step values for each. In addition, the user can provide a list of named regions for which to test the segmentation. This allows to not test the entire image, but rather to test specific areas in the image that might be characterstic for specific types of land cover.

Two optimization functions are available via the optimization_function parameter: A simple sum of the normalized criteria values as defined by Espindola et al (2006), or the F-function as defined by Johnson et al (2015). The optimization functions use intra-segment variance and inter-segment spatial autocorrelation. For the latter, the user can chose to use either Moran's I or Geary's C.

The user can chose between non-hierarchical (default) and hierarchical segmentation using the h flag. The latter uses each segmentation at a given threshold level as seed for the segmentation at the next threshold level within a given minimum segment size. Note that this leads to less optimal parallelization as for a given minsize, all segmentations have to be done sequentially (see below).

The segment_map parameter allows to provide a basename for keeping the number_best best segmentations for each given region according to the optimization function. The resulting map names will be a combination of this basename, the region, the threshold, the minsize and the rank of the map within the region according to its optimization criteria value.

The module uses high-level parallelization (running different segmentations in parallel and then running the collection of parameter values in parallel). The parameter processes allows to define how many processes should be run in parallel. Note that when using hierarchical segmentation the number of parallel processes is limited to the number of different mininum segment sizes to test.

The k flag allows to keep all segmentation maps created during the process.


The module depends on the addon r.neighborhoodmatrix which needs to be installed.

Any unsupervised optimization can at best be a support to the user. Visual and other types of validation of the results, possibly comparing several of the "best" solutions, remain necessary.

Even though the module allows the user to test different minsizes, it is probably better to run the module with minsizes=1 and then adapt the minsize in the final run of i.segment depending on the desired minimum mapping unit.

In hierarchical segmentation mode, the processes are divided between different calls to i.segment.hierarchical. This means that when some of these calls are much longer than others, the work load is not evenly divided between cores. This is especially true if one explores a large number of thresholds with minsizes of significantly different levels.


g.region -au n=220767 s=220392 w=638129 e=638501 res=1 save=region1
g.region -au n=222063 s=221667 w=637659 e=638058 res=1 save=region2 ortho input=ortho_2001_t792_1m
i.segment.uspo group=ortho regions=region1,region2 \ 
	output=ortho_parameters.csv segment_map=ortho_uspo \
	threshold_start=0.02 threshold_stop=0.21 threshold_step=0.02 \
	minsizes=5,10,15 number_best=5 processes=4 memory=4000


G. M. Espindola , G. Camara , I. A. Reis , L. S. Bins , A. M. Monteiroi (2006), Parameter selection for region-growing image segmentation algorithms using spatial autocorrelation, International Journal of Remote Sensing, Vol. 27, Iss. 14, pp. 3035-3040,

B. A. Johnson, M. Bragais, I. Endo, D. B. Magcale-Macandog, P. B. M. Macandog (2015), Image Segmentation Parameter Optimization Considering Within- and Between-Segment Heterogeneity at Multiple Scale Levels: Test Case for Mapping Residential Areas Using Landsat Imagery, ISPRS International Journal of Geo-Information, 4(4), pp. 2292-2305,




Moritz Lennert

Last changed: $Date: 2017-05-12 14:36:51 +0200 (Fri, 12 May 2017) $


Available at: i.segment.uspo source code (history)

Main index | Imagery index | Topics index | Keywords index | Graphical index | Full index

© 2003-2017 GRASS Development Team, GRASS GIS 7.2.3svn Reference Manual