FindCircles Method

NI Vision for Visual Basic

FindCircles Method

Syntax

CWIMAQVision.FindCircles SourceImage, DestImage, CirclesReport [, MinRadius = 1] [, MaxRadius = 10]

Return Type

Long

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

Purpose

Separates overlapping circular objects and classifies them based on their radius, surface area, and perimeter. Starting from a binary image, it finds the radius and center of the circular objects even when multiple circular objects overlap. In addition, this method can trace the circles in the destination image. It constructs and uses a Danielsson distance map to determine the radius of each object.

Remarks

Use this method with U8 images.

This method operates on circles with radii less than or equal to 256 pixels.

Parameters

SourceImage As CWIMAQImage

The image to process.

DestImage As CWIMAQImage

The resulting image.

CirclesReport As CWIMAQCirclesReport

On return, a report containing the measurements for circles whose radius lies between the given MinRadius and MaxRadius.

MinRadius As Variant

[Optional] The smallest radius (in pixels) to detect. Circles with radii smaller than this value do not appear in the destination image or in the CirclesReport.

This parameter has a default value of 1.

MaxRadius As Variant

[Optional] The largest radius (in pixels) to detect. Circles with radii larger than this value do not appear in the destination image or in the CirclesReport.

This parameter has a default value of 10.

Example

'This example requires you to have a ListBox named List1 on the form.
Dim i As New CWIMAQImage
Dim report As New CWIMAQCirclesReport
Dim j

'Threshold the image in Viewer1 inplace.
CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _
                        128, 255, , 255

'Separate and classify circular objects in the image in Viewer1
'and store the results in i
CWIMAQVision1.FindCircles CWIMAQViewer1.Image, i, report, , 100

'Display the core areas in the ListBox
List1.Clear
For j = 1 To report.Count
    List1.AddItem report(j).CoreArea
Next