SimpleEdge Method

NI Vision for Visual Basic

SimpleEdge Method

Syntax

CWIMAQVision.SimpleEdge SourceImage, Points, LevelType, Edges [, Process = cwimaqEdgeProcessAll] [, SubPixel = False] [, Threshold = 128] [, Hysteresis = 0]

Return Type

Long

On success, this method returns 0. On failure, this method returns a negative number.

Purpose

Finds step edges along a collection of pixel coordinates. This method can return the first, both the first and the last, or all the edges found.

Remarks

Use this method with U8, I16, and SGL images.

You can use this method in conjunction with the RegionsProfile method to obtain the Points that define the path.

Parameters

SourceImage As CWIMAQImage

The image in which to find edges.

Points As CWIMAQPoints

The coordinates of the path along which the method detects the edges.

LevelType As CWIMAQLevelTypes

Specifies whether the values in Threshold and Hysteresis are absolute or relative.

Edges As CWIMAQPoints

On return, the coordinates of the edge points.

Process As Variant

[Optional] A CWIMAQEdgeProcesses constant that determines the type of search. The following values are valid: cwimaqEdgeProcessFirst, cwimaqEdgeProcessFirstAndLast, and cwimaqEdgeProcessAll.

This parameter has a default value of cwimaqEdgeProcessAll.

SubPixel As Variant

[Optional] Determines the accuracy required for the location of the edge coordinates. Setting this parameter to False enables fast edge detection. A subpixel localization of the edges is obtained when this parameter is True. The subpixel result is computed using a local quadratic interpolation.

This parameter has a default value of False.

Threshold As Variant

[Optional] Specifies where an edge occurs. Can be either absolute or relative. Absolute threshold is based on the pixel values. Relative threshold is expressed as a percentage of the pixel-value range found along the path defined by the pixel coordinates.

If this parameter is not supplied, the default value is 128 if LevelType is cwimaqLevelTypeAbsolute and 50 if LevelType is cwimaqLevelTypeRelative.

This parameter has a default value of 128.

Hysteresis As Variant

[Optional] A value that helps determine edges in noisy images. Can be either absolute or relative. If a pixel value crosses the given threshold value but does not exceed the value by the hysteresis value, the method does not consider the pixel to be part of an edge.

This parameter has a default value of 0.

Example

' Find the edge coordinates along a path defined by regions
' on Viewer1 and display the coordinates on the image.
Private Sub Run_Click()
    Dim profileReport As New CWIMAQProfileReport
    Dim edgeCoordinates As New CWIMAQPoints
    Dim j
    
    ' Find the coordinates of the points along the path
    ' defined by the regions on Viewer1
    CWIMAQVision1.RegionsProfile CWIMAQViewer1.Image, _
                                 CWIMAQViewer1.Regions, _
                                 profileReport
    
    ' Find the edges along the selected path
    CWIMAQVision1.SimpleEdge CWIMAQViewer1.Image, _
                             profileReport(1).Coordinates, _
                             cwimaqLevelTypeAbsolute, _
                             edgeCoordinates
    
    ' Display the results
    For j = 1 To edgeCoordinates.Count
        Dim oval As New CWIMAQOval
        oval.Initialize edgeCoordinates(j).X - 4, _
                        edgeCoordinates(j).Y - 4, _
                        8, 8
        CWIMAQViewer1.Image.Overlays(1).DrawOval oval, _
                                                 cwimaqOverlayModePaint, _
                                                 vbRed
    Next
End Sub

Rotating Part Example

See Also

CWIMAQEdgeProcesses