Centroid2 Method

NI Vision for Visual Basic

Centroid2 Method

Syntax

CWIMAQVision.Centroid2 SourceImage, Centroid [, MaskImage]

Return Type

Long

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

Purpose

Computes the centroid of an image.

Remarks

Use this method with image types U8, I16, and SGL. MaskImage must be a U8 image.

Parameters

SourceImage As CWIMAQImage

The image whose centroid the method calculates.

Centroid As CWIMAQPoint

On return, the centroid.

MaskImage As Variant

[Optional] A CWIMAQImage object that specifies the region in the image to use for computing the centroid. The method uses only those source image pixels whose corresponding mask pixels are non-zero to compute the centroid. Do not set this parameter if you want the method to use the whole image in the centroid calculation.

Example

Dim centroid As New CWIMAQPoint
Dim maskImage As New CWIMAQImage

'Do something here to populate the maskImage

'Calculate the centroid of the Image in Viewer1 using
'maskImage as a mask.
CWIMAQVision1.Centroid2 CWIMAQViewer1.Image, centroid, maskImage