Average Method

NI Vision for Visual Basic

Average Method

Syntax

CWIMAQVision.Average SourceImage, Operand, DestImage

Return Type

Long

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

Purpose

Computes the average of two source images or an image and a constant.

Remarks

Use this method with image types U8, I16, and SGL.

If Operand is an image and Operand is of a type that contains more bits per pixel than SourceImage, Operand and DestImage must be the same type of image. Otherwise, SourceImage and DestImage must be the same type of image.

Parameters

SourceImage As CWIMAQImage

The first input image.

Operand As Variant

Either the second input image or a constant. Constants are rounded down if SourceImage is encoded as an integer.

DestImage As CWIMAQImage

The resulting image. It can be one of the source images.

Example

Dim i As New CWIMAQImage

' Average a constant and an image in Viewer1.
' Store the result in i
CWIMAQVision1.Average CWIMAQViewer1.Image, 50, i

' Average image i and the image in Viewer1.
' Do the averaging inplace (store the result in i)
CWIMAQVision1.Average CWIMAQViewer1.Image, i, i