Adaptive filter

This tool performs a type of adaptive filter on a raster image. An adaptive filter can be used to reduce the level of random noise (shot noise) in an image. The algorithm operates by calculating the average value in a moving window centred on each grid cell. If the absolute difference between the window mean value and the centre grid cell value is beyond a user-defined threshold, the grid cell in the output image is assigned the mean value, otherwise it is equivalent to the original value. Therefore, the algorithm only modifies the image where grid cell values are substantially different than their neighbouring values.

Neighbourhood size, or filter size, is determined by the user-defined x and y dimensions. These dimensions should be odd, positive integer values, e.g. 3, 5, 7, 9... The user may also define the neighbourhood shape as either squared or rounded. A rounded neighbourhood approximates an ellipse; a rounded neighbourhood with equal x and y dimensions approximates a circle.

NoData values in the input image are ignored during filtering. When the neighbourhood around a grid cell extends beyond the edge of the grid, NoData values are assigned to these sites. The output raster is of the float data type and continuous data scale.

See Also:

Scripting:

The following is an example of a Python script that uses this tool:

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "input.dep"
outputFile = wd + "output.dep"
xDim = "3"
yDim = "3"
diffFromMean = "2"
rounded = "false"
reflectEdges = "true"
args = [inputFile, outputFile, xDim, yDim,
diffFromMean, rounded, reflectEdges]
pluginHost.runPlugin("FilterAdaptive", args, False)

This is a Groovy script also using the tool:

def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "input.dep"
def outputFile = wd + "output.dep"
def xDim = "3"
def yDim = "3"
def diffFromMean = "2"
def rounded = "false"
def reflectEdges = "true"
String[] args = [inputFile, outputFile, xDim, yDim,
diffFromMean, rounded, reflectEdges]
pluginHost.runPlugin("FilterAdaptive", args, false)

Credits: