ParticleFilter Method

NI Vision for Visual Basic

ParticleFilter Method

Syntax

CWIMAQVision.ParticleFilter SourceImage, DestImage, ParticleFilterData, RemoveMatches [, Connectivity8 = True]

Return Type

Long

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

Purpose

Obsolete—Use ParticleFilter2 instead. 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 images.

The calculation modifies the border of the source image. The border must be at least one pixel wide if you use connectivity-4 or two pixels wide if you use connectivity-8.

Parameters

SourceImage As CWIMAQImage

The image on which to perform the particle filter.

DestImage As CWIMAQImage

The result of the processing.

ParticleFilterData As CWIMAQParticleFilterData

The criteria on which the particle filtering takes place.

RemoveMatches As Boolean

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

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 i As New CWIMAQImage
    Dim data As New CWIMAQParticleFilterData
    ' Select particles that contain less than 100 pixels or
    ' more than 300 pixels and remove them.
    data.Add
    data(1).Parameter = cwimaqParticleArea
    data(1).MinValue = 100
    data(1).MaxValue = 300
    data(1).Exclude = True
    ' Perform the particle filter operation and 
    ' store the result in i
    CWIMAQVision1.ParticleFilter CWIMAQViewer1.Image, i, data, True
End Sub

See Also

ParticleFilter2