4.9.4 Exact Large-Scale Mean-Shift segmentation, step 2

Second step of the exact Large-Scale Mean-Shift segmentation workflow.

Detailed description

This application performs the second step of the exact Large-Scale Mean-Shift segmentation workflow (LSMS). Filtered range image and spatial image should be created with the MeanShiftSmoothing application, with modesearch parameter disabled. If spatial image is not set, the application will only process the range image and spatial radius parameter will not be taken into account. This application will produce a labeled image where neighbor pixels whose range distance is below range radius (and optionally spatial distance below spatial radius) will be grouped together into the same cluster. For large images one can use the nbtilesx and nbtilesy parameters for tile-wise processing, with the guarantees of identical results. Please note that this application will generate a lot of temporary files (as many as the number of tiles), and will therefore require twice the size of the final result in term of disk space. The cleanup option (activated by default) allows removing all temporary file as soon as they are not needed anymore (if cleanup is activated, tmpdir set and tmpdir does not exists before running the application, it will be removed as well during cleanup). The tmpdir option allows defining a directory where to write the temporary files. Please also note that the output image type should be set to uint32 to ensure that there are enough labels available.

Parameters

This section describes in details the parameters available for this application. Table 4.142, page 774 presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is LSMSSegmentation.





Parameter key

Parameter type

Parameter description




in

Input image

Filtered image

inpos

Input image

Spatial image

out

Output image

Output Image

ranger

Float

Range radius

spatialr

Float

Spatial radius

minsize

Int

Minimum Region Size

tilesizex

Int

Size of tiles in pixel (X-axis)

tilesizey

Int

Size of tiles in pixel (Y-axis)

tmpdir

Directory

Directory where to write temporary files

cleanup

Boolean

Temporary files cleaning

inxml

XML input parameters file

Load otb application from xml file

outxml

XML output parameters file

Save otb application to xml file











Table 4.142: Parameters table for Exact Large-Scale Mean-Shift segmentation, step 2.

Example

To run this example in command-line, use the following:

otbcli_LSMSSegmentation -in smooth.tif -inpos position.tif -out segmentation.tif -ranger 15 -spatialr 5 -minsize 0 -tilesizex 256 -tilesizey 256

To run this example from Python, use the following code snippet:

#!/usr/bin/python 
 
# Import the otb applications package 
import otbApplication 
 
# The following line creates an instance of the LSMSSegmentation application 
LSMSSegmentation = otbApplication.Registry.CreateApplication("LSMSSegmentation") 
 
# The following lines set all the application parameters: 
LSMSSegmentation.SetParameterString("in", "smooth.tif") 
 
LSMSSegmentation.SetParameterString("inpos", "position.tif") 
 
LSMSSegmentation.SetParameterString("out", "segmentation.tif") 
 
LSMSSegmentation.SetParameterFloat("ranger", 15) 
 
LSMSSegmentation.SetParameterFloat("spatialr", 5) 
 
LSMSSegmentation.SetParameterInt("minsize", 0) 
 
LSMSSegmentation.SetParameterInt("tilesizex", 256) 
 
LSMSSegmentation.SetParameterInt("tilesizey", 256) 
 
# The following line execute the application 
LSMSSegmentation.ExecuteAndWriteOutput()

Limitations

This application is part of the Large-Scale Mean-Shift segmentation workflow (LSMS) and may not be suited for any other purpose.

Authors

This application has been written by David Youssefi.

See also

These additional ressources can be useful for further information: