Line-detection filter

This tool can be used to perform one of four 3x3 line-detection filters on a raster image. These filters can be used to find one-cell-thick vertical, horizontal, or angled (135-degrees or 45-degrees) lines in an image. Notice that line-finding is a similar application to edge-detection. Common edge-detection filters include the Sobel and Prewitt filters. The kernel weights for each of the four line-detection filters are as follows:

Vertical

-1 2 -1
-1 2 -1
-1 2 -1

Horizontal

-1 -1 -1
2 2 2
-1 -1 -1

135-degrees

2 -1 -1
-1 2 -1
-1 -1 2

45-degrees

-1 -1 2
-1 2 -1
2 -1 -1

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"
direction = "Horizontal"
absoluteValues = "false" args = [inputFile, outputFile, direction, absoluteValues]
pluginHost.runPlugin("FilterLineDetection", 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 direction = "135-degrees"
def absoluteValues = "false" String[] args = [inputFile, outputFile, direction, absoluteValues]
pluginHost.runPlugin("FilterLineDetection", args, false)

Credits: