Rake Method

NI Vision for Visual Basic

Rake Method

Syntax

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

Return Type

Long

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

Purpose

Finds edges along a set of parallel lines defined inside a rectangular region. Edges are determined based on their contrast and slope.

Remarks

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

The following figure illustrates the rake:

Parameters

SourceImage As CWIMAQImage

The image in which to find the edges.

Regions As CWIMAQRegions

The rectangle or rotated rectangular region within which the edge detection is performed.

ScanDirection As CWIMAQRakeScanDirections

Defines the direction along which edges are searched for along the lines.

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.

This parameter has a default value of 5.

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 a rectangle or rotated rectangle 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 rake with subpixel accuracy of one-tenth. Find only the first edge along each line
    EdgeOptions.SubPixelAccuracy = cwimaqSubPixelOneTenth
    CWIMAQVision1.Rake CWIMAQViewer1.Image, CWIMAQViewer1.Regions, cwimaqScanLeftToRight, _
                       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