ParticleReport Method

NI Vision for Visual Basic

ParticleReport Method

Syntax

CWIMAQVision.ParticleReport SourceImage, ParticleReport [, Calibrated = False] [, Connectivity8 = True]

Return Type

Long

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

Purpose

Detects and returns commonly-used properties of particles in a binary image.

Remarks

This method modifies the source image. If you need the original source image, create a copy of the image using the CWIMAQVision.Copy method before using this method.

Use this method with U8, I16 and SGL images.

Parameters

SourceImage As CWIMAQImage

The image on which to get information about the particles.

ParticleReport As CWIMAQParticleReport

On return, the report containing information about the particles in the image.

Calibrated As Variant

[Optional] Whether to take calibrated measurements on the particles in the image.

This parameter has a default value of False.

Connectivity8 As Variant

[Optional] Set this parameter to True to use connectivity-8 to determine whether particles are touching. Set this parameter to False to use connectivity-4 to determine whether particles are touching. For more information about connectivity, refer to the NI Vision Concepts Manual.

This parameter has a default value of True.

Example

Private Sub Run_Click()
    Dim report1 As New CWIMAQParticleReport
    Dim i

    ' Threshold the image in place
    CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, , , , 255

    ' Do particle analysis
    CWIMAQVision1.ParticleReport CWIMAQViewer1.Image, report1

    ' For each particle, display Area and the Bounding Rectangle
    For i = 1 To report1.Count
        Dim Area
        Dim Text As String
        Dim textOptions As New CWIMAQTextOptions
        Dim rotatedRect As CWIMAQRotatedRectangle
        Area = report1(i).Area
        Text = "A: " & CStr(Area)
        CWIMAQViewer1.Image.Overlays(1).DrawRectangle report1(i).BoundingRectangle, cwimaqDrawModeFrame
        textOptions.HorizontalAlignment = cwimaqHorizontalTextAlignmentCenter
        textOptions.Style = cwimaqTextStyleNormal
        textOptions.FontName = "Arial"
        textOptions.Size = 16
        textOptions.ForeColor = vbBlue
        Set rotatedRect = report1(i).BoundingRectangle.MakeRotatedRectangle
        CWIMAQViewer1.Image.Overlays(1).DrawText rotatedRect.Center, textOptions, Text
    Next
End Sub

See Also

Threshold

ParticleMeasurement