Spoke Method

NI Vision for Visual Basic

Spoke Method

Syntax

CWIMAQVision.Spoke SourceImage, Regions, ScanDirection, EdgeCoordinatesReport [, EdgeOptions] [, Process = cwimaqEdgeProcessAll] [, StepSize] [, LineCoordinates]

Return Type

Long

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

Purpose

Finds edges along radial lines specified inside an annular region. The edges are determined based on their contrast and slope.

Remarks

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

The following figure illustrates the spoke edge search tool:

Parameters

SourceImage As CWIMAQImage

The image in which to find the edges.

Regions As CWIMAQRegions

Defines the annular region within which the edge detection is performed.

ScanDirection As CWIMAQSpokeScanDirections

Defines the direction along which the edges are searched for.

EdgeCoordinatesReport As CWIMAQEdgeCoordinatesReport

On return, a report containing information about the detected edges.

EdgeOptions As Variant

[Optional] A CWIMAQEdgeOptions object that defines the characteristics that the method uses to find the edges and the parameters it needs for subpixel analysis of the edges.

Process As Variant

[Optional] A CWIMAQEdgeProcesses constant that determines the type of search. The method can return the first edge, both the first and the last edge, or all edges found along the paths.

This parameter has a default value of cwimaqEdgeProcessAll.

StepSize As Variant

[Optional] Defines the distance, in pixels, between the parallel lines inside the rectangular region.

LineCoordinates As Variant

[Optional] On return, a CWIMAQLines collection containing the lines that were used for the search.

Example

'This routine assumes that you have an annulus selected on the viewer
Private Sub Run_Click()
    'Declarations
    Dim EdgeCoordinatesReport As New CWIMAQEdgeCoordinatesReport
    Dim EdgeOptions As New CWIMAQEdgeOptions
    Dim LineCoordinates As New CWIMAQLines
    Dim I As Integer
    
    'Perform a spoke with subpixel accuracy of one-tenth. Find only the first edge along each line
    EdgeOptions.SubPixelAccuracy = cwimaqSubPixelOneTenth
    CWIMAQVision1.Spoke CWIMAQViewer1.Image, CWIMAQViewer1.Regions, cwimaqScanOutsideToInside, _
                        EdgeCoordinatesReport, EdgeOptions, cwimaqEdgeProcessFirst, 10, LineCoordinates
                       
    'Overlay the search lines
    For I = 1 To LineCoordinates.Count
        CWMachineVision1.DrawLineWithArrows CWIMAQViewer1.Image.Overlays(1), LineCoordinates(I), False, _
                                            True, vbBlue
    Next I
    
    'Overlay edge points found
    With EdgeCoordinatesReport.FirstEdgePoints
        For I = 1 To .Count
            CWMachineVision1.DrawCircularPoint CWIMAQViewer1.Image.Overlays(1), .Item(I), 5, _
                                               cwimaqOverlayModePaint, vbRed
        Next I
    End With
End Sub

See Also

CWIMAQEdgeOptions

CWIMAQEdgeProcesses

CWIMAQLines