Particle Method
Syntax
CWIMAQVision.Particle SourceImage, ParticlesReport [, Connectivity8 = True]
Return Type
On success, this method returns 0. On failure, this method returns a negative number.
Purpose
Obsolete—Use ParticleReport instead. Detects and measures particles. The method returns a set of measurements made from 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 images.
Parameters
SourceImage As CWIMAQImage
The image containing particles to analyze. The image must be binary (a thresholded U8 image) with a border size of at least 2. Particles are areas in the image whose pixels have non-zero values.
ParticlesReport As CWIMAQFullParticleReport
On return, a report containing a set of measurements on the particles.
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 report As New CWIMAQFullParticleReport
Dim Area
Dim Orientation
Dim X
Dim Y
Dim i
' Threshold the image inplace
CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _
, , , 255
' Do particle analysis
CWIMAQVision1.Particle CWIMAQViewer1.Image, report
' Calculate the area of each particle
CWIMAQVision1.CalculateCoefficients CWIMAQViewer1.Image, _
cwimaqParticleArea, _
report, Area
' Calculate the orientation of each particle
CWIMAQVision1.CalculateCoefficients CWIMAQViewer1.Image, _
cwimaqParticleOrientation, _
report, Orientation
' Calculate the center of mass for each particle
CWIMAQVision1.CalculateCoefficients CWIMAQViewer1.Image, _
cwimaqParticleCenterMassX, _
report, X
CWIMAQVision1.CalculateCoefficients CWIMAQViewer1.Image, _
cwimaqParticleCenterMassY, _
report, Y
' For each particle, display the Area, Orientation, and mark the center of mass
For i = 0 To report.Count - 1
Dim Text As String
Dim oval As New CWIMAQOval
Dim point As New CWIMAQPoint
Dim textOptions As New CWIMAQTextOptions
Text = "A: " & CStr(Area(i)) & " O: " & Format(Orientation(i), "##0.00")
oval.Initialize X(i) - 4, Y(i) - 4, 8, 8
CWIMAQViewer1.Image.Overlays(1).DrawOval oval, cwimaqDrawModePaint
point.Initialize X(i), Y(i)
textOptions.HorizontalAlignment = cwimaqHorizontalTextAlignmentCenter
textOptions.Style = cwimaqTextStyleNormal
textOptions.FontName = "Arial"
textOptions.Size = 16
textOptions.ForeColor = vbWhite
CWIMAQViewer1.Image.Overlays(1).DrawText point, textOptions, Text
Next
End Sub
Blob Analysis Example
Particle Orientation Example
Circle Distance Example