ParticleFilter3 Method

NI Vision for Visual Basic

ParticleFilter3 Method

Syntax

CWIMAQVision.ParticleFilter3 SourceImage, DestImage, ParticleFilterData, RemoveMatches, NumParticles [, Connectivity8 = True] [, RejectBorderParticles = False] [, Regions]

Return Type

Long

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

Purpose

Filters (keeps or removes) particles in an image according to their morphological measurements.

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 perform the particle filter.

DestImage As CWIMAQImage

The result of the processing.

ParticleFilterData As CWIMAQParticleFilter2Data

The criteria on which the particle filtering takes place.

RemoveMatches As Boolean

Sets the action that is performed on the objects fitting the criteria specified by Criteria. True removes the particles fitting the criteria. False keeps the particles fitting the criteria.

NumParticles As Variant

On return, the number of particles remaining in the destination image.

Connectivity8 As Boolean

[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.

RejectBorderParticles As Boolean

[Optional] If True, particles touching the Regions will be filtered out of the image.

This parameter has a default value of False.

Regions As Variant

[Optional] The region outside of which all particles will be filtered out.

Example

Private Sub Run_Click()
    Dim i As New CWIMAQImage
    Dim data As New CWIMAQParticleFilter2Data
    ' Select particles that contain less than 100 pixels or
    ' more than 300 pixels and remove them.
    data.Add
    data(1).Parameter = cwimaqMeasurementArea
    data(1).MinValue = 100
    data(1).MaxValue = 300
    data(1).Exclude = True
    data(1).Calibrated = False
    ' Perform the particle filter operation and 
    ' store the result in i
    CWIMAQVision1.ParticleFilter3 CWIMAQViewer1.Image, i, data, True
End Sub