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:
'v' (Vertical)
. | . | . |
-1 | 2 | -1 |
-1 | 2 | -1 |
-1 | 2 | -1 |
'h' (Horizontal)
. | . | . |
-1 | -1 | -1 |
2 | 2 | 2 |
-1 | -1 | -1 |
'45' (Northeast-Southwest)
. | . | . |
-1 | -1 | 2 |
-1 | 2 | -1 |
2 | -1 | -1 |
'135' (Northwest-Southeast)
. | . | . |
2 | -1 | -1 |
-1 | 2 | -1 |
-1 | -1 | 2 |
The user must specify the variant
, including 'v', 'h', '45', and '135', for vertical, horizontal, northeast-southwest, and northwest-southeast directions respectively. The user may also optionally clip the output image distribution tails by a specified amount (e.g. 1%).
def line_detection_filter(self, raster: Raster, variant: str = "v", abs_values: bool = False, clip_tails: float = 0.0) -> Raster: ...