Sobel filter

This tool performs a 3x3 or 5x5 Sobel edge-detection filter on a raster image. The Sobel filter is similar to the Prewitt filter, in that it identifies areas of high slope in the input image through the calculation of slopes in the x and y directions. The Sobel edge-detection filter, however, gives more weight to nearer cell values within the moving window, or kernel. In the case of the 3x3 Sobel filter, the x and y slopes are estimated by convolution with the following kernels:


-1 0 1
-2 0 2
-1 0 1


1 2 1
0 0 0
-1 -2 -1

Each grid cell in the output image is then assigned the square-root of the squared sum of the x and y slopes.

NoData values in the input image are replaced with the average value of all valid cells within the kernel. This is also the procedure when the neighbourhood around a grid cell extends beyond the edge of the grid. The output raster is of the float data type and continuous data scale.

See Also:


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

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "input.dep"
outputFile = wd + "output.dep"
filterSize = "3 x 3"
reflectEdges = "true"
args = [inputFile, outputFile, filterSize, reflectEdges]
pluginHost.runPlugin("FilterGaussian", 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 filterSize = "3 x 3"
def reflectEdges = "true"
String[] args = [inputFile, outputFile, filterSize, reflectEdges]
pluginHost.runPlugin("FilterGaussian", args, false)