Smoothing

Apply a smoothing filter to an image

Description

This application applies a smoothing filter to an image. Three methods can be used: a mean filter, a gaussian filter based on [1], or an anisotropic diffusion using the Perona-Malik algorithm [2].

Parameters

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

Mean options

Radius -type.mean.radius int Default value: 2
Kernel’s radius (in pixels)

Gaussian options

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.

Anisotropic Diffusion options

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).

Examples

From the command-line:

# 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

From 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()

See also

[1] Tony Lindeberg Discrete Scale-Space Theory and the Scale-Space Primal Sketch. Dissertation. Royal Institute of Technology, Stockholm, Sweden. May 1991
[2] Pietro Perona and Jitendra Malik, Scale-space and edge detection using anisotropic diffusion, IEEE Transactions on Pattern Analysis Machine Intelligence, vol. 12, pp. 629-639, 1990.
itk::MeanImageFilter (mean mode)
itk::DiscreteGaussianImageFilter (gaussian mode)
itk::GradientAnisotropicDiffusionImageFilter (anidif mode).