Module EdgeDetect
See Also

Aim of module

Provides different raster based edge detection algorithms (e.g. Canny).

General description

The aim of opalsEdgeDetect is to provide an interface for different edge detectors. Based on an input raster file and an appropriate set of parameters for the respective edge detection algorithm, a binary output raster is derived containing the detected edge pixels.

See Also
Module EdgeDetect

Module EdgeDetect is implemented using the OPALS modules Convolution and Algebra. Please note, that currently only Canny edge detection is implemented.

Canny algorithm

A comprehensive description of the Canny edge detection can be found here. In a nutshell, the Canny algorithm consists of the following steps:

  1. Calculation of gradient in two orthogonal directions (based on the first derivative of Gaussian operator, Gx and Gy).
  2. Non-maximum suppression (resulting in 1-pixel-edge lines)
  3. Application of upper and lower threshold.
  4. Edge tracking by hysteresis. Starting with pixels exhibiting gradients > upper threshold, the edges are extended (in both directions) until the gradient falls below the lower threshold. Finally, weak edges which are not connected to strong edges, are removed.

Implementation details

Please note, that while the Canny algorithm is a generic edge detector, the main application in the context of OPALS is to detect topographic breaklines (i.e. surface slope disontinuities like dams, ridges, ditches, embankments...). In this special case, a slope raster (pixel value = surface gradient in degree) turned out to be the best choice (c.f. Mandlburger et al., 2016).

Parameter description

-inFileinput raster file
Type: opals::Path
Remarks: mandatory
The input raster image in GDAL supported format,
-outFileoutput raster file
Type: opals::Path
Remarks: estimable
Path of (binary) raster image file in GDAL supported format containing edge pixels.
Estimation rule: The current directory and the name (body) of the input file are used as file name basis. Additionally, the postfix '_edge' and the output format extension are appended (e.g. '_edge.tif').
-oFormatraster file format [GTiff,EHdr...]
Type: opals::String
Remarks: estimable
Use GDAL driver names like GTiff, EHdr... . It is recommended to use output formats supporting a binary (0|1) data type.
Estimation rule: The output format is estimated based on the extension of the output file (*.tif->GTiff, *.bil->EHdr, *.dtm->SCOP...).
-detectoredge detection method
Type: opals::EdgeDetector
Remarks: default=Canny

Possible values:  
  Canny ... Canny Edge Detector

Please note, that currently only the Canny edge detection is implemented.

-sigmaSmoothgaussian smoothing sigma
Type: float
Remarks: default=1
The standard deviation of the gaussian function for smoothing gradient computation using first-derivative of gaussian function. the value should be a positive number larger than 0.25.The kernel radius is three times parameter's value.
-thresholdthreshold values
Type: opals::Array<double,2>
Remarks: default=2 10
Depending on the edge detection methods, different threshold values are required. Canny: upper/lower threshold. The upper threshold denotes the minimum gradient necessary to start an edge. Starting from such an feature pixel the edge is extended in both directions until the gradient falls below the lower threshold.
-tempDirectorypath for intermediate files
Type: opals::Path
Remarks: estimable
Directory path for storing intermediate files (gradient and exposition images, etc.).
Estimation rule: Current working directory + '/tempEdgeDetect'
-debugOutFileindicator for preserving temporary products
Type: bool
Remarks: default=0
If activated, all intermediate products (gradient and exposition images, etc.) are preserved. Otherwise, the entire temporary directory (-tempDirectory) is deleted at program termination.
-limit2D clipping window
Type: opals::GridLimit
Remarks: optional
If no user defined limits are specified or -limit is even skipped, the entire xy-extents of the input raster model are used.


The data used in the following examples can be found in the $OPALS_ROOT/demo/ directory. As a prerequisite, please use the following commands to generate a DTM from the ALS ground points stored in dataset flyover.laz.

opalsImport -inFile flyover.laz -tileSize 100 -coord_ref_sys EPSG:5650
opalsGrid -inFile flyover.odm -outFile flyover_dtm.tif -interpolation movingPlanes -neighbours 8 -searchRadius 2 -selMode quadrant
opalsGridFeature -inFile flyover_dtm.tif -feature slpDeg

Now we can use Module EdgeDetect to detect the approximate 2D course of break lines from the resulting DTM slope raster. We specify the input grid (slope raster), the resulting binary raster image file containing the edge pixels, the kernel radius for gaussian smoothing, and the lower and upper threshold.

opalsEdgeDetect -inFile flyover_dtm_slpDeg.tif -outFile flyover_dtm_slpDeg_canny.tif -sigmaSmooth 1 -threshold 1 4

effects of smoothing on the edge detection result

opalsEdgeDetect -inFile flyover_dtm_slpDeg.tif -outFile flyover_dtm_slpDeg_canny_s1.tif -sigmaSmooth 0.5 -threshold 1 4
parameter sigmaSmooth=0.5
opalsEdgeDetect -inFile flyover_dtm_slpDeg.tif -outFile flyover_dtm_slpDeg_canny_s2.tif -sigmaSmooth 1 -threshold 1 4
parameter sigmaSmooth=1
opalsEdgeDetect -inFile flyover_dtm_slpDeg.tif -outFile flyover_dtm_slpDeg_canny_s3.tif -sigmaSmooth 1.5 -threshold 1 4
parameter sigmaSmooth=1.5
opalsEdgeDetect -inFile flyover_dtm_slpDeg.tif -outFile flyover_dtm_slpDeg_canny_s4.tif -sigmaSmooth 2 -threshold 1 4
parameter sigmaSmooth=2