LSMSSegmentation¶
此应用程序执行大规模Mean-Shift分割工作流(LSM)的第二步 [1] 。
描述¶
这个应用程序将生成一个带标签的图像,其中范围距离小于范围半径(以及可选的低于空间半径的空间距离)的相邻像素将一起分组到同一簇中。对于较大的图像,可以使用tilesizex和tilesizey参数进行平铺处理,并保证得到相同的结果。
过滤后的距离图像和空间图像应使用 MeanShiftSmoothing 应用程序输出(fout和foutpos) [2] ,禁用modesearch参数。如果没有设置空间图像,应用程序将只处理距离图像,而不会考虑空间半径参数。
请注意,此应用程序将生成大量临时文件(与磁贴的数量一样多),因此需要的磁盘空间是最终结果的两倍。Cleanup选项(默认情况下激活)允许在不再需要临时文件时立即删除它们(如果激活了Cleanup、设置了tmpdir并且在运行应用程序之前tmpdir不存在,则在清理过程中也会将其删除)。Tmpdir选项允许定义写入临时文件的目录。
还请注意,输出图像类型应设置为uint32,以确保有足够的标签可用。
The output of this application can be passed to the LSMSSmallRegionsMerging [3] or LSMSVectorization [4] applications to complete the LSMS workflow.
参数¶
Filtered image -in image
Mandatory
The filtered image, corresponding to the fout output parameter of the MeanShiftSmoothing application.
- Filtered position image
-inpos image
- 过滤后的位置图像,对应于MeanShift平滑应用程序的foutpos输出参数。
Output labeled Image -out image [dtype]
Mandatory
This output contains the segmented image, where each pixel value is the unique integer label of the segment it belongs to. It is recommended to set the pixel type to uint32.
Spatial radius -spatialr float
Default value: 5
Threshold on Spatial distance to consider pixels in the same segment. A good value is half the spatial radius used in the MeanShiftSmoothing application (spatialr parameter).
Range radius -ranger float
Default value: 15
Threshold on spectral signature euclidean distance (expressed in radiometry unit) to consider pixels in the same segment. A good value is half the range radius used in the MeanShiftSmoothing application (ranger parameter).
Minimum Segment Size -minsize int
Default value: 0
Minimum Segment Size. If, after the segmentation, a segment is of size lower than this criterion, the segment is discarded.
Size of tiles in pixel (X-axis) -tilesizex int
Default value: 500
Size of tiles along the X-axis for tile-wise processing.
Size of tiles in pixel (Y-axis) -tilesizey int
Default value: 500
Size of tiles along the Y-axis for tile-wise processing.
Directory where to write temporary files -tmpdir directory
This applications need to write temporary files for each tile. This parameter allows choosing the path where to write those files. If disabled, the current path will be used.
Temporary files cleaning -cleanup bool
Default value: true
If activated, the application will try to remove all temporary files it created.
实例¶
从命令行执行以下操作:
otbcli_LSMSSegmentation -in smooth.tif -inpos position.tif -out segmentation.tif -spatialr 5 -ranger 15 -minsize 0 -tilesizex 256 -tilesizey 256
来自Python的评论:
import otbApplication
app = otbApplication.Registry.CreateApplication("LSMSSegmentation")
app.SetParameterString("in", "smooth.tif")
app.SetParameterString("inpos", "position.tif")
app.SetParameterString("out", "segmentation.tif")
app.SetParameterFloat("spatialr", 5)
app.SetParameterFloat("ranger", 15)
app.SetParameterInt("minsize", 0)
app.SetParameterInt("tilesizex", 256)
app.SetParameterInt("tilesizey", 256)
app.ExecuteAndWriteOutput()
局限性¶
此应用程序是大规模均值漂移分割工作流(LSM)的一部分 [1] 并且可能不适合用于任何其他目的。此应用程序与内存中连接不兼容,因为它执行自己的内部流。