FillHole Method

NI Vision for Visual Basic

FillHole Method

Syntax

CWIMAQVision.FillHole SourceImage, DestImage [, Connectivity8 = True]

Return Type

Long

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

Purpose

Fills holes in particles. The function fills the holes with a pixel value of 1.

Remarks

Use this method with U8 images.

The method does not fill areas touching the edge of the image that appear to be holes because these areas could be either holes or areas of concavity.

This function is optimized for MMX.

Parameters

SourceImage As CWIMAQImage

The image containing particles with holes to fill.

DestImage As CWIMAQImage

The resulting image.

Connectivity8 As Variant

[Optional] Specifies how the algorithm determines whether an adjacent pixel belongs to the same or to a different particle.

This parameter has a default value of True.

Example

Dim i As New CWIMAQImage

' Threshold the image on Viewer1 inplace.
CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _
                        128, 255, , 255

' Fill the holes in the image on Viewer1 that have connectivity-4 and
' store the result in i.
CWIMAQVision1.FillHole CWIMAQViewer1.Image, i, False

' Fill the holes in the image on Viewer1 that have connectivity-8.
' Do this operation in place (Store the result in the image on Viewer1).
CWIMAQVision1.FillHole CWIMAQViewer1.Image, CWIMAQViewer1.Image