Distance Method

NI Vision for Visual Basic

Distance Method

Syntax

CWIMAQVision.Distance SourceImage, DestImage [, StructuringElement]

Return Type

Long

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

Purpose

Creates a distance map. The method encodes the pixel value of a particle as a function of the distance of the pixel from the particle border. For a more precise but slower algorithm, use Danielsson.

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.

All images must be U8 images.

The method modifies the border of the source image. The border must be at least half as large as the larger of the structuring element dimensions.

Parameters

SourceImage As CWIMAQImage

The image that the method uses to compute the distance map.

DestImage As CWIMAQImage

The resulting image.

StructuringElement As Variant

[Optional] A CWIMAQStructuringElement object that describes the structuring element applied to the image. The method uses a 3 x 3 structuring element if you do not set this parameter.

For more information on structuring elements, refer to the NI Vision Concepts Manual.

Example

Dim i As New CWIMAQImage
Dim structuringElement As New CWIMAQStructuringElement

' Threshold the image in Viewer1 and store the results in i.
CWIMAQVision1.Threshold CWIMAQViewer1.Image, i, 128, 255, , 255

' Create a distance map of i.
' Store the result in the image in Viewer2.
CWIMAQVision1.Distance i, CWIMAQViewer2.Image

' View the results on Viewer2 using a binary palette.
CWIMAQViewer2.Palette.Type = cwimaqPaletteBinary

See Also

CWIMAQStructuringElement

Danielsson