LargeScaleMeanShift - Large-Scale MeanShift¶
Large-scale segmentation using MeanShift
This application chains together the 4 steps of the MeanShit framework, that is the MeanShiftSmoothing , the LSMSSegmentation , the LSMSSmallRegionsMerging  and the LSMSVectorization .
This application can be a preliminary step for an object-based analysis.
It generates a vector data file containing the regions extracted with the MeanShift algorithm. The spatial and range radius parameters allow to adapt the sensitivity of the algorithm depending on the image dynamic and resolution. There is a step to remove small regions whose size (in pixels) is less than the given ‘minsize’ parameter. These regions are merged to a similar neighbor region. In the output vectors, there are additional fields to describe each region. In particular the mean and standard deviation (for each band) is computed for each region using the input image as support. If an optional ‘imfield’ image is given, it will be used as support image instead.
This section describes in details the parameters available for this application. Table  presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is LargeScaleMeanShift .
|||Table: Parameters table for Large-Scale MeanShift.|
|Parameter Key||Parameter Name||Parameter Type|
|in||Input Image||Input image|
|minsize||Minimum Segment Size||Int|
|tilesizex||Size of tiles in pixel (X-axis)||Int|
|tilesizey||Size of tiles in pixel (Y-axis)||Int|
|mode vector||Segmentation as vector output||Choice|
|mode raster||Standard segmentation with labeled raster output||Choice|
|mode.vector.imfield||Support image for field computation||Input image|
|mode.vector.out||Output GIS vector file||Output File name|
|mode.raster.out||The output raster image||Output image|
|cleanup||Temporary files cleaning||Boolean|
|ram||Available RAM (Mb)||Int|
|inxml||Load otb application from xml file||XML input parameters file|
|outxml||Save otb application to xml file||XML output parameters file|
Input Image: The input image can be any single or multiband image. Beware of pontential imbalance between bands ranges as it may alter euclidean distance.
Spatial radius: Radius of the spatial neighborhood for averaging. Higher values will result in more smoothing and higher processing time.
Range radius: Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider neighborhood pixel for averaging. Higher values will be less edge-preserving (more similar to simple average in neighborhood), whereas lower values will result in less noise smoothing. Note that this parameter has no effect on processing time.
Minimum Segment Size: Minimum Segment Size. If, after the segmentation, a segment is of size lower than this criterion, the segment is merged with the segment that has the closest sepctral signature.
Size of tiles in pixel (X-axis): Size of tiles along the X-axis for tile-wise processing.
Size of tiles in pixel (Y-axis): Size of tiles along the Y-axis for tile-wise processing.
Output mode: Type of segmented output. Available choices are:
- Segmentation as vector output: In this mode, the application will produce a vector file or database and compute field values for each region.
- Support image for field computation: This is an optional support image that can be used to compute field values in each region. Otherwise, the input image is used as support.
- Output GIS vector file: The output GIS vector file, representing the vectorized version of the segmented image where the features of the polygons are the radiometric means and variances.
- Standard segmentation with labeled raster output: In this mode, the application will produce a standard labeled raster.
- The output raster image: It corresponds to the output of the small region merging step.
Temporary files cleaning: If activated, the application will try to clean all temporary files it created.
Available RAM (Mb): Available memory for processing (in MB).
Load otb application from xml file: Load otb application from xml file.
Save otb application to xml file: Save otb application to xml file.
To run this example in command-line, use the following:
otbcli_LargeScaleMeanShift -in QB_1_ortho.tif -spatialr 4 -ranger 80 -minsize 16 -mode.vector.out regions.shp
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 LargeScaleMeanShift application LargeScaleMeanShift = otbApplication.Registry.CreateApplication("LargeScaleMeanShift") # The following lines set all the application parameters: LargeScaleMeanShift.SetParameterString("in", "QB_1_ortho.tif") LargeScaleMeanShift.SetParameterInt("spatialr", 4) LargeScaleMeanShift.SetParameterFloat("ranger", 80) LargeScaleMeanShift.SetParameterInt("minsize", 16) LargeScaleMeanShift.SetParameterString("mode.vector.out", "regions.shp") # The following line execute the application LargeScaleMeanShift.ExecuteAndWriteOutput()
- These additional resources can be useful for further information:
-  MeanShiftSmoothing LSMSSegmentation LSMSSmallRegionsMerging LSMSVectorization