平滑¶
将平滑滤镜应用于图像
描述¶
此应用程序将平滑滤镜应用于图像。可以使用三种方法:均值滤波、基于高斯滤波的 [1] ,或使用Perona-Malik算法的各向异性扩散 [2] 。
参数¶
Input Image -in image
Mandatory
Input image to smooth.
Output Image -out image [dtype]
Mandatory
Output smoothed image.
Smoothing Type -type [mean|gaussian|anidif]
Default value: anidif
Smoothing kernel to apply
- Mean
- Gaussian
- Anisotropic Diffusion
高斯选项¶
Standard deviation -type.gaussian.stdev float
Default value: 2
Standard deviation of the gaussian kernel used to filter the image
Maximum error -type.gaussian.maxerror float
Default value: 0.01
The algorithm will size the discrete kernel so that the error resulting from truncation of the kernel is no greater than maxerror.
Maximum kernel width -type.gaussian.maxwidth int
Default value: 32
Set the kernel to be no wider than maxwidth pixels, even if type.gaussian.maxerror demands it.
各向异性扩散选项¶
Time Step -type.anidif.timestep float
Default value: 0.125
Time step that will be used to discretize the diffusion equation
Nb Iterations -type.anidif.nbiter int
Default value: 10
Number of iterations needed to get the result
Conductance -type.anidif.conductance float
Default value: 1
Controls the sensitivity of the conductance term in the diffusion equation. The lower it is the stronger the features will be preserved
Available RAM (MB) -ram int
Default value: 256
Available memory for processing (in MB).
实例¶
从命令行执行以下操作:
# Image smoothing using a mean filter.
otbcli_Smoothing -in Romania_Extract.tif -out smoothedImage_mean.png uchar -type mean
# Image smoothing using an anisotropic diffusion filter.
otbcli_Smoothing -in Romania_Extract.tif -out smoothedImage_ani.png float -type anidif -type.anidif.timestep 0.1 -type.anidif.nbiter 5 -type.anidif.conductance 1.5
来自Python的评论:
# Image smoothing using a mean filter.
import otbApplication
app = otbApplication.Registry.CreateApplication("Smoothing")
app.SetParameterString("in", "Romania_Extract.tif")
app.SetParameterString("out", "smoothedImage_mean.png")
app.SetParameterOutputImagePixelType("out", 1)
app.SetParameterString("type","mean")
app.ExecuteAndWriteOutput()
# Image smoothing using an anisotropic diffusion filter.
import otbApplication
app = otbApplication.Registry.CreateApplication("Smoothing")
app.SetParameterString("in", "Romania_Extract.tif")
app.SetParameterString("out", "smoothedImage_ani.png")
app.SetParameterOutputImagePixelType("out", 6)
app.SetParameterString("type","anidif")
app.SetParameterFloat("type.anidif.timestep", 0.1)
app.SetParameterInt("type.anidif.nbiter", 5)
app.SetParameterFloat("type.anidif.conductance", 1.5)
app.ExecuteAndWriteOutput()