Back to Aurora Vision Library website

You are here: Start » Function Reference » Computer Vision » 2D Edge Detection » DetectEdges_AsPaths_Mask

DetectEdges_AsPaths_Mask


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Extracts subpixel-precise paths that represent continuous edges. Faster, yet less accurate version.

Applications: Consistent detection of contours of variable or unpredictable shape, e.g. screw thread outline or a custom piece of textile.

Syntax

C++
C#
 
void avl::DetectEdges_AsPaths_Mask
(
	const avl::Image& inImage,
	atl::Optional<const avl::Region&> inRoi,
	avl::EdgeMaskFilter::Type inEdgeMaskFilter,
	float inEdgeThreshold,
	float inEdgeHysteresis,
	atl::Optional<float> inMaxJoiningDistance,
	float inMaxJoiningAngle,
	float inJoiningDistanceBalance,
	atl::Optional<float> inJoiningEndingLength,
	float inMinEdgeLength,
	atl::Array<avl::Path>& outEdges,
	avl::Image& diagGradientMagnitudeImage,
	avl::Region& diagEdgeRegion
)

Parameters

Name Type Range Default Description
Input value inImage const Image& Image from which edges will be extracted
Input value inRoi Optional<const Region&> NIL Region of the image from which edges will be extracted
Input value inEdgeMaskFilter EdgeMaskFilter::Type Type of edge filter used for computing gradients
Input value inEdgeThreshold float 0.0 - 35.0f Sufficient edge strength; edges of that strength will always be detected
Input value inEdgeHysteresis float 0.0 - 15.0f Value by which the edge threshold is decreased for edge points neighboring with sufficiently strong edges
Input value inMaxJoiningDistance Optional<float> 0.0 - NIL Maximal distance between edges that can be joined
Input value inMaxJoiningAngle float 0.0 - 180.0 30.0f Maximal allowed angle between edges being joined
Input value inJoiningDistanceBalance float 0.0 - 1.0 0.0f Determines how important distance between edges is according to their angle difference
Input value inJoiningEndingLength Optional<float> 1.0 - NIL Determines the length of the edge end used for edge angle computing
Input value inMinEdgeLength float 0.0 - 0.0f Minimal length of an edge
Output value outEdges Array<Path>& Paths representing found edges
Diagnostic input diagGradientMagnitudeImage Image& Visualization of the gradient magnitude
Diagnostic input diagEdgeRegion Region& Region representing found edges

Description

The operation extracts edges from the inRoi region in the inImage image and stores the result in the array of paths outEdges. The extraction process is the same as in DetectEdges_AsRegion_Mask, the only difference being the data type of the result. This filter returns an array of subpixel-precise paths rather than region computed by DetectEdges_AsRegion_Mask.

The extraction process starts from gradient computing, what is done using chosen non-recursive filter with fixed size mask.

On the so computed gradient image threshold with hysteresis (as in ThresholdImage_Hysteresis) is performed with inEdgeThreshold and inEdgeHysteresis parameters. After this step only gradients which are strong enough are present. The resulting edge region can be much too thick, thus it has to be thinned. To achieve this, the non-maximum suppression is used. Every pixel with at least one of its neighbors having larger gradient is no longer considered to be an edge pixel (only neighbors in the direction of pixel's gradient matter).

The positions of found edges are then determined with subpixel precision. The so extracted edges can then undergo further post-processing, if necessary. An edge can be joined with another one in its vicinity, but only if the distance between them is not greater than inMaxJoiningDistance and neither of them forms an angle greater than inMaxJoiningAngle with the segment connecting their endings. The inJoiningEndingLength parameter determines what part of the edge ending is used to determine above mentioned turn angle. If it is set to Nil, only the last edge segment is decisive. Sometimes two or more edges can be joined with an edge. Because only one of them can be, each of the candidates is evaluated based on the distance from the fixed edge's ending and the turn angle associated with their connection. The greater inJoiningDistanceBalance is, the less influence on the evaluation score the latter value has. After the joining phase, edges that are shorter than inMinEdgeLength are removed from the final results.

Examples

DetectEdges_AsPaths_Mask performed on the sample image with inEdgeMaskFilter = Sobel, inEdgeThreshold = 20, inEdgeHysteresis = 5.

Hardware Acceleration

This operation supports automatic parallelization for multicore and multiprocessor systems.

Errors

List of possible exceptions:

Error type Description
DomainError Unsupported edge mask filter in DetectEdges_AsPaths_Mask.

See Also