F_VN_LocateEdgesExp2
Locate the points of multiple occuring edges inside a specified search window with subpixel accuracy. (expert function)
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_LocateEdgesExp2 : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipEdgePoints : Reference To ITcVnContainer;
END_VAR
VAR_IN_OUT
aStartPoint : TcVnPoint2_REAL;
aEndPoint : TcVnPoint2_REAL;
END_VAR
VAR_INPUT
nNumEdges : UDINT;
eEdgeDirection : ETcVnEdgeDirection;
bAlternateDirection : BOOL;
fMinStrength : REAL;
nSearchLines : UDINT;
fSearchLineDist : REAL;
nMaxThickness : UDINT;
nSubpixelsIterations : UDINT;
fApproxPrecision : REAL;
eAlgorithm : ETcVnEdgeDetectionAlgorithm;
fRangeCutoffFactor : REAL;
ipEdgeStrengths : Reference To ITcVnContainer;
bAvgEdgeStrengths : BOOL;
hrPrev : HRESULT;
END_VAR
VAR_OUTPUT
fAvgStrength : REAL;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (1 channel) | |
ipEdgePoints |
Reference To ITcVnContainer |
Returns the detected edge points (ContainerType_Vector_Vector_TcVnPoint2_REAL) |
nNumEdges |
UDINT |
The (maximum) number of edges to search for |
eEdgeDirection |
Specification of the edge direction to search for | |
bAlternateDirection |
BOOL |
If true, eEdgeDirection is alternated after each detected edge. Else, only edges with eEdgeDirection are searched for. |
fMinStrength |
REAL |
Specification of the minimum strength (intensity difference) of the edge to search for |
nSearchLines |
UDINT |
Width of the search window, i.e. the number of search lines (1, 3, 5, 7, ...), centered around the line specified by aStartPoint and aEndPoint |
fSearchLineDist |
REAL |
Distance between the search lines in pixels (> 0) |
nMaxThickness |
UDINT |
Specification of the maximum thickness of the edge to search for, which means fMinStrength must be reached within nMaxThickness pixels |
nSubpixelsIterations |
UDINT |
Specifies the number of subpixels (for INTERPOLATION, 10 - 20 usually is sufficient) or maximum number of iterations for optimizing the parameters (for APPROX_ERF and APPROX_GAUSSIAN, 50 - 100 usually is sufficient) |
fApproxPrecision |
REAL |
Specifies the approximation precision for APPROX_ERF and APPROX_GAUSSIAN (0.001 usually is sufficient, unused for INTERPOLATION) |
eAlgorithm |
Selection of the edge detection algorithm | |
fRangeCutoffFactor |
REAL |
Relative edge strength factor to cut off the range of pixels used for approximation. Negative numbers are valid to include noise, i.e. intensity differences in the other direction. At most nMaxThickness pixels are used in each direction. |
ipEdgeStrengths |
Reference To ITcVnContainer |
Returns the detected edge strengths (optional, set to 0 if not required; ContainerType_Vector_Vector_REAL or ContainerType_Vector_REAL, depending on bAvgEdgeStrengths) |
bAvgEdgeStrengths |
BOOL |
If true, ipEdgeStrengths returns the average strength per edge instead of individual strengths for each search line |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
In/Outputs
Name |
Type |
Description |
---|---|---|
aStartPoint |
Position from which to start the search process (in the direction of aEndPoint) | |
aEndPoint |
Position where the search process ends |
Outputs
Name |
Type |
Description |
---|---|---|
fAvgStrength |
REAL |
Returns the average strength of the detected edges |
Further information
The F_VN_LocateEdgesExp2 function is the expert version of F_VN_LocateEdges. It contains additional parameters.
Parameter
Input image
The ipSrcImage
input image must be a 1-channel grayscale image.
Localized points (Return value)
The ipEdgePoints
container returns the localized points of the linear edges.
The search window
First, a search window has to be defined to determine where and in which direction to search for an edge. This is done using the aStartPoint
, aEndPoint
and nSearchLines
parameters. The search window results from the search line from aStartPoint
to aEndPoint
and parallel to it (nSearchLines
- 1) / 2 search lines in each direction, each with 1 pixel distance. Thus nSearchLines
defines the number of search lines and must always have an odd value.

Edge strength (Return value)
The fAvgStrength
return value displays the actual contrast of the localized edges (averaged over all search lines).
Parameters for edge localization
The remaining parameters are explained in detail in the chapter Edge localization.
Edge thicknesses (Return value)
The detected edge thicknesses are returned via ipEdgeStrengths
. Depending on bAvgEdgeStrengths
, either the average thickness per edge is returned as the container type ContainerType_Vector_REAL
or the individual thicknesses for each search line are returned as ContainerType_Vector_Vector_REAL
. This parameter is optional and can be set to 0 if it is not required.
Application
The localization of a linear edge with expert parameters looks like this, for example:
hr := F_VN_LocateEdgesExp2(
ipSrcImage := ipImageIn,
ipEdgePoints := ipEdgePoints,
aStartPoint := aStartPoint,
aEndPoint := aEndPoint,
nNumEdges := nNumEdges,
eEdgeDirection := eDirection,
bAlternateDirection := bAlternateDirection,
fMinStrength := fMinStrength,
nSearchLines := nSearchLines,
fSearchLineDist := fSearchLineDist,
nMaxThickness := nMaxThickness,
nSubpixelsIterations := nSubpixIter,
fApproxPrecision := 0.001,
eAlgorithm := eAlgorithm,
fRangeCutoffFactor := 0.135,
ipEdgeStrengths := ipEdgeStrengths,
bAvgEdgeStrengths := bAvgEdgeStrengths,
hrPrev := hr,
fAvgStrength => fAvgStrength);
Related functions
- LocateCircularArc for localizing proportional circular arcs
- LocateEdge for localizing linear edges
- LocateEdges for localizing several linear edges
- LocateEllipse for localizing complete ellipses
Required License
TC3 Vision Metrology 2D