RemoveParticle Method
Syntax
CWIMAQVision.RemoveParticle SourceImage, DestImage [, NumberOfErosions = 2] [, KeepLarge = True] [, StructuringElement] [, Connectivity8 = True]
Return Type
On success, this method returns 0. On failure, this method returns a negative number.
Purpose
Eliminates or keeps particles resistant to a specified number of erosions. The particles that are kept are exactly the same as those found in the original source 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.
The source image for a morphological transformation must have been created with a border capable of supporting the size of the structuring element. A 3 x 3 structuring element requires a minimal border of 1, a 5 x 5 structuring element requires a minimal border of 2, and so on. The border size of the destination image is not important.
This method is optimized for MMX.
Parameters
SourceImage As CWIMAQImage
The image in which to remove the particles.
DestImage As CWIMAQImage
The resulting image.
NumberOfErosions As Variant
[Optional] The number of erosions to perform.
This parameter has a default value of 2.
KeepLarge As Variant
[Optional] Set this parameter to True to keep the particles remaining after the erosion. Set this parameter to False to keep the particles eliminated by the erosion.
This parameter has a default value of True.
StructuringElement As Variant
[Optional] A CWIMAQStructuringElement object that describes the structuring element applied to the image. The method applies a 3 x 3 structuring element if you do not set this parameter.
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 structuringElement As New CWIMAQStructuringElement ' Find the particles resistant to 3 erosions 'in the image in Viewer1. ' Store the result in i. CWIMAQVision1.RemoveParticle CWIMAQViewer1.Image, i, 3, , _ structuringElement ' Remove all particles with connectivity-4 resistant ' to 3 erosions in i. ' Do the operation in place (store the result in i) CWIMAQVision1.RemoveParticle i, i, 3, False, , True End Sub