Segmentation Method

NI Vision for Visual Basic

Segmentation Method

Syntax

CWIMAQVision.Segmentation SourceImage, DestImage

Return Type

Long

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

Purpose

Starting from a labeled image, calculates the zones of influence between particles. Each labeled particle dilates/grows until the particles reach their neighbors, at which time this growth is stopped.

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 and I16 images.

The segmentation modifies the border of the source image. The border must be at least one pixel wide.

Use Label2 to label the image prior to using Segmentation.

Parameters

SourceImage As CWIMAQImage

The image to segment.

DestImage As CWIMAQImage

The destination image.

Example

Private Sub Run_Click()
    Dim i As New CWIMAQImage
    Dim numParticles
    
    ' Threshold the image in Viewer1.
    CWIMAQVision1.Threshold CWIMAQViewer1.Image, CWIMAQViewer1.Image, _
                            128, 255, , 255
    
    ' Label the image in Viewer1 and store the result in i.
    CWIMAQVision1.Label CWIMAQViewer1.Image, i, numParticles
    
    ' Segment the image in i.
    ' Do the operation in-place (Store the result in i).
    CWIMAQVision1.Segmentation i, i
    
    ' View i in Viewer2 using a binary palette.
    CWIMAQViewer2.Attach i
    CWIMAQViewer2.Palette = cwimaqPaletteBinary
End Sub

See Also

Label2