分割

对图像执行分割,并输出栅格或矢量文件。在向量模式下,支持大型输入数据集。

描述

这个应用程序允许在多光谱图像上执行各种分割算法。可用的分割算法有两种不同的Mean-Shift分割算法(一种是多线程的)、根据用户定义的标准的简单的基于像素的连通分量、以及根据强度梯度(光谱带向量的范数)的分水岭。应用程序有两种不同的模式,这会影响其输出的性质。

在栅格模式下,应用程序的输出是标识分割区域的唯一标签的经典图像。标记的输出可以传递给 ColorMapping 应用程序来渲染具有对比颜色的区域。请注意,此模式会将整个输入图像加载到内存中,因此无法处理大图像。

要分割大数据,可以使用矢量模式。在这种情况下,应用程序的输出是向量文件或数据库。输入图像被分割成多个平铺(其大小可以使用TleSize参数设置),每个平铺被加载、使用所选算法进行分割、矢量化并写入输出文件或数据库。这种分段行为确保了内存永远不会超载,并且可以处理任何大小的图像。向量模式中几乎没有更多的选项。简化选项允许根据用户定义的公差简化几何体(即移除多边形中的节点)。缝合选项尝试将与可能已被平铺方案分割的分段区域对应的多边形缝合在一起。

参数

Input Image -in image Mandatory
The input image to segment

Segmentation algorithm -filter [meanshift|cc|watershed|mprofiles] Default value: meanshift
Choice of segmentation algorithm (mean-shift by default)

  • Mean-Shift
    OTB implementation of the Mean-Shift algorithm (multi-threaded).
  • Connected components
    Simple pixel-based connected-components algorithm with a user-defined connection condition.
  • Watershed
    The traditional watershed algorithm. The height function is the gradient magnitude of the amplitude (square root of the sum of squared bands).
  • Morphological profiles based segmentation
    Segmentation based on morphological profiles, as described in Martino Pesaresi and Jon Alti Benediktsson, Member, IEEE: A new approach for the morphological segmentation of high resolution satellite imagery. IEEE Transactions on geoscience and remote sensing, vol. 39, NO. 2, February 2001, p. 309-320.

均值漂移期权

Spatial radius -filter.meanshift.spatialr int Default value: 5
Spatial radius of the neighborhood.

Range radius -filter.meanshift.ranger float Default value: 15
Range radius defining the radius (expressed in radiometry unit) in the multispectral space.

Mode convergence threshold -filter.meanshift.thres float Default value: 0.1
Algorithm iterative scheme will stop if mean-shift vector is below this threshold or if iteration number reached maximum number of iterations.

Maximum number of iterations -filter.meanshift.maxiter int Default value: 100
Algorithm iterative scheme will stop if convergence hasn't been reached after the maximum number of iterations.

Minimum region size -filter.meanshift.minsize int Default value: 100
Minimum size of a region (in pixel unit) in segmentation. Smaller clusters will be merged to the neighboring cluster with the closest radiometry. If set to 0 no pruning is done.

连接的组件选项

Condition -filter.cc.expr string Mandatory
User defined connection condition, written as a mathematical expression. Available variables are 'p(i)b(i)', 'intensity_p(i)' and 'distance'. Substitute (i) by the desired value. Example of expression: intensity_p2 > 0.5.

分水岭选项

Depth Threshold -filter.watershed.threshold float Default value: 0.01
Depth threshold Units in percentage of the maximum depth in the image.

Flood Level -filter.watershed.level float Default value: 0.1
flood level for generating the merge tree from the initial segmentation (between 0 and 1)

基于形态轮廓的分割选项

Profile Size -filter.mprofiles.size int Default value: 5
Size of the profiles

Initial radius -filter.mprofiles.start int Default value: 1
Initial radius of the structuring element (in pixels)

Radius step -filter.mprofiles.step int Default value: 1
Radius step along the profile (in pixels)

Threshold of the final decision rule -filter.mprofiles.sigma float Default value: 1
Profiles values under the threshold will be ignored.


Processing mode -mode [vector|raster] Default value: vector
Choice of processing mode, either raster or large-scale.

  • Tile-based large-scale segmentation with vector output
    In this mode, the application will output a vector file or database, and process the input image piecewise. This allows performing segmentation of very large images.
  • Standard segmentation with labeled raster output
    In this mode, the application will output a standard labeled raster. This mode can not handle large data.

具有矢量输出选项的基于平铺的大规模分割

Output vector file -mode.vector.out filename [dtype] Mandatory
The output vector file or database (name can be anything understood by OGR)

Writing mode for the output vector file -mode.vector.outmode [ulco|ovw|ulovw|ulu] Default value: ulco
This allows one to set the writing behaviour for the output vector file. Please note that the actual behaviour depends on the file format.

  • Update output vector file, only allow creating new layers
    The output vector file is opened in update mode if existing. If the output layer already exists, the application stops, leaving it untouched.
  • Overwrite output vector file if existing.
    If the output vector file already exists, it is completely destroyed (including all its layers) and recreated from scratch.
  • Update output vector file, overwrite existing layer
    The output vector file is opened in update mode if existing. If the output layer already exists, it si completely destroyed and recreated from scratch.
  • Update output vector file, update existing layer
    The output vector file is opened in update mode if existing. If the output layer already exists, the new geometries are appended to the layer.

Mask Image -mode.vector.inmask image
Only pixels whose mask value is strictly positive will be segmented.

8-neighbor connectivity -mode.vector.neighbor bool Default value: false
Activate 8-Neighborhood connectivity (default is 4).

Stitch polygons -mode.vector.stitch bool Default value: true
Scan polygons on each side of tiles and stitch polygons which connect by more than one pixel.

Minimum object size -mode.vector.minsize int Default value: 1
Objects whose size is below the minimum object size (area in pixels) will be ignored during vectorization.

Simplify polygons -mode.vector.simplify float Default value: 0.1
Simplify polygons according to a given tolerance (in pixel). This option allows reducing the size of the output file or database.

Layer name -mode.vector.layername string Default value: layer
Name of the layer in the vector file or database (default is Layer).

Geometry index field name -mode.vector.fieldname string Default value: DN
Name of the field holding the geometry index in the output vector file or database.

Tiles size -mode.vector.tilesize int Default value: 1024
User defined tiles size for tile-based segmentation. Optimal tile size is selected according to available RAM if null.

Starting geometry index -mode.vector.startlabel int Default value: 1
Starting value of the geometry index field

OGR options for layer creation -mode.vector.ogroptions string1 string2...
A list of layer creation options in the form KEY=VALUE that will be passed directly to OGR without any validity checking. Options may depend on the file format, and can be found in OGR documentation.

带有标注栅格输出选项的标准分段

Output labeled image -mode.raster.out image [dtype] Mandatory
The output labeled image.

实例

从命令行执行以下操作:

# Example of use with vector mode and watershed segmentation
otbcli_Segmentation -in QB_Toulouse_Ortho_PAN.tif -mode vector -mode.vector.out SegmentationVector.sqlite -filter watershed

# Example of use with raster mode and mean-shift segmentation
otbcli_Segmentation -in QB_Toulouse_Ortho_PAN.tif -mode raster -mode.raster.out SegmentationRaster.tif uint16 -filter meanshift

来自Python的评论:

# Example of use with vector mode and watershed segmentation
import otbApplication

app = otbApplication.Registry.CreateApplication("Segmentation")

app.SetParameterString("in", "QB_Toulouse_Ortho_PAN.tif")
app.SetParameterString("mode","vector")
app.SetParameterString("mode.vector.out", "SegmentationVector.sqlite")
app.SetParameterString("filter","watershed")

app.ExecuteAndWriteOutput()
# Example of use with raster mode and mean-shift segmentation
import otbApplication

app = otbApplication.Registry.CreateApplication("Segmentation")

app.SetParameterString("in", "QB_Toulouse_Ortho_PAN.tif")
app.SetParameterString("mode","raster")
app.SetParameterString("mode.raster.out", "SegmentationRaster.tif")
app.SetParameterOutputImagePixelType("mode.raster.out", 3)
app.SetParameterString("filter","meanshift")

app.ExecuteAndWriteOutput()

局限性

在栅格模式下,应用程序无法处理大型输入图像。对于非常大的输入图像,矢量模式的拼接步骤可能会变得很慢。MeanShift过滤结果取决于使用的线程数。对输入图像的幅值进行分水岭和多尺度测地线形态分割。此应用程序不处理任何数据值。任何数据像素都不会被视为常规像素,这可能会导致意外的分割结果和崩溃。

另请参阅