Module EdgeDetect
See also
opals::IEdgeDetect

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.
GridLimit: Defines xy-limits for output grid/raster datasets. The limit coordinates specified by left/lower/right/upper either refer to pixel centers (default) or corners, and may optionally get rounded to multiples of the grid size.
Syntax: ['center'|'corner']['round']['(' left lower right upper ')']

Short examples

Generate a Edge from DTM file

opalsImport -inf flyover.laz
opalsGrid -inf flyover.odm -out flyover_dtm.tif
opalsGridFeature -inf flyover_dtm.tif -feature slope
opalsAlgebra -inf flyover_dtm_slope.tif -formula "atan(r[0]/100)*180/pi"
opalsEdgeDetect -inf flyover_dtm.tif -threshold 1 4 -sigmaSmooth 1

Examples

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

References

Author
gm,paryan
Date
8.1.2017
@ quadrant
quadrant-wise nn selection, ie. nn per quadrant, then 2nd nn per quadrant, ...
@ movingPlanes
moving (tilted) plane interpolation
@ coord_ref_sys
default coordinate reference system (EPSG Code, WKT string or PRJ-File)
opalsAlgebra is the executable file of Module Algebra
Definition: ModuleExecutables.hpp:13
opalsImport is the executable file of Module Import
Definition: ModuleExecutables.hpp:113
opalsEdgeDetect is the executable file of Module EdgeDetect
Definition: ModuleExecutables.hpp:68
@ slope
steepest slope [%]
Definition: GridFeature.hpp:16
@ threshold
threshold (opalsEdgeDetect)
opalsGrid is the executable file of Module Grid
Definition: ModuleExecutables.hpp:93
@ slpDeg
steepest slope [deg]
Definition: GridFeature.hpp:17
@ sigmaSmooth
gaussian smoothing sigma (opalsEdgeDetect)
@ feature
Use a statistic feature of the boundary gap points for filling.
@ formula
formula string for albegraic grid computations (opalsAlgebra)
opalsGridFeature is the executable file of Module GridFeature
Definition: ModuleExecutables.hpp:98