MeanShiftSmoothing¶
此应用程序使用MeanShift算法对图像进行平滑处理。
描述¶
MeanShift [1,2,3] 是一种迭代的边缘保持图像平滑算法,常用于图像处理和图像分割的第一步。MeanShift算法适用于多光谱图像。
在第一次迭代中,对于输入图像的任何给定像素,滤波值对应于空间上比空间半径参数(Spatialr)更接近的邻域像素的平均光谱特征,并且具有到输入像素的欧几里得距离小于距离半径(Ranger)的光谱特征,即,在空间和光谱特征上都接近的像素。随后的迭代将通过考虑像素签名对应于在先前迭代期间计算的平均光谱签名以及像素位置对应于用于计算平均签名的像素的平均位置来重复该过程。当达到最大迭代次数(MAXIER)时,或者当位置和频谱签名在迭代之间没有太大变化时,根据收敛阈值(TRES),算法停止。如果使用modesearch选项,则如果空间位置达到已收敛的像素,则收敛也将停止。这将加速收敛,但代价是结果的稳定性。
该应用程序输出最终平均光谱特征的图像(Fout),还可以选择性地输出输入像素位置和收敛后最终像素位置之间的2D位移场(Foutpos)。
请注意,计算光谱签名之间的欧几里得距离可能不准确,并且可以在使用此应用程序之前应用诸如颜色空间变换或图像归一化等技术。还请注意,大多数卫星图像的噪声模型不是高斯模型,因为噪声方差与辐射亮度线性相关(辐射亮度越高,噪声方差越大)。为了考虑此类噪波模型,应用程序提供了范围半径渐变选项(Rangeramp),该选项将随中心像素强度线性变化范围半径。默认值为1。(无渐变)。
此应用程序是中描述的大规模MeanShift方法的第一步 [4] 。这两个输出(fout和foutpos)都可以传递到大规模MeanShift分段应用程序 [5] 。如果应用程序用于大规模MeanShift,则应关闭modesearch选项。
这个应用程序有几个输出图像,并支持“多写”。不是独立地计算和写入每个图像,而是以同步的方式为每个输出写入流图像块。输出图像将逐条计算,使用可用的RAM计算条带大小,并且可以使用流扩展文件名(类型、模式和值)指定用户定义的流模式。请注意,可以使用多写扩展文件名选项禁用多写,在这种情况下,将逐个写入输出图像。请注意,MPI编写器不支持多重写入。
参数¶
Input Image -in image
Mandatory
The input image can be any single or multiband image. Beware of potential imbalance between bands ranges as it may alter euclidean distance.
Spectral filtered output -fout image [dtype]
Mandatory
This output image contains the final average spectral signatures of each pixel. The output type should be at least as wide as the input image type. Floating point encoding is advised. This output can be used as input image (in) of the LSMSSegmentation application [4,5].
- Spatial filtered displacement output
-foutpos image [dtype]
- 该输出图像包含输入像素空间位置与收敛后的最终位置之间的2D位移。浮点编码是必需的。此输出可用作LSMSS图像处理应用程序的输入图像(in [4,5] 。
Spatial radius -spatialr int
Default value: 5
Radius of the spatial neighborhood for averaging. Higher values will result in more smoothing and higher processing time.
Range radius -ranger float
Default value: 15
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.
Mode convergence threshold -thres float
Default value: 0.1
Algorithm will stop if update of average spectral signature and spatial position is below this threshold.
Maximum number of iterations -maxiter int
Default value: 100
Algorithm will stop if convergence threshold is not met after the maximum number of iterations.
Range radius ramp coefficient -rangeramp float
Default value: 0
Vary the range radius linearly with the central pixel intensity (experimental).
Mode search -modesearch bool
Default value: false
If activated pixel iterative convergence is stopped if the path crosses an already converged pixel. Be careful, with this option, the result will slightly depend on thread number and the results will not be stable (see [4] for more details).
Available RAM (MB) -ram int
Default value: 256
Available memory for processing (in MB).
实例¶
从命令行执行以下操作:
otbcli_MeanShiftSmoothing -in maur_rgb.png -fout smooth.tif -foutpos position.tif -spatialr 16 -ranger 16 -thres 0.1 -maxiter 100
来自Python的评论:
import otbApplication
app = otbApplication.Registry.CreateApplication("MeanShiftSmoothing")
app.SetParameterString("in", "maur_rgb.png")
app.SetParameterString("fout", "smooth.tif")
app.SetParameterString("foutpos", "position.tif")
app.SetParameterInt("spatialr", 16)
app.SetParameterFloat("ranger", 16)
app.SetParameterFloat("thres", 0.1)
app.SetParameterInt("maxiter", 100)
app.ExecuteAndWriteOutput()
局限性¶
当打开模式搜索时,由于多线程,应用程序在每次执行时会产生略有不同的结果。结果也不会稳定 [4] 。