Prewitt filter

This tool performs a 3x3 Prewitt edge-detection filter on a raster image. The Prewitt filter is similar to the Sobel 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. The Prewitt filter estimates the x and y slopes by convolution with the following kernels:

x-direction:

-1 0 1
-1 0 1
-1 0 1

y-direction:

1 1 1
0 0 0
-1 -1 -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:

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"
reflectEdges = "true"
args = [inputFile, outputFile, reflectEdges]
pluginHost.runPlugin("FilterPrewitt", 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 reflectEdges = "true"
String[] args = [inputFile, outputFile, reflectEdges]
pluginHost.runPlugin("FilterPrewitt", args, false)

Credits: