AbsoluteDifference Method

NI Vision for Visual Basic

AbsoluteDifference Method

Syntax

CWIMAQVision.AbsoluteDifference SourceImage, Operand, DestImage

Return Type

Long

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

Purpose

Subtracts one image from another or a constant from an image and returns the absolute value of the difference.

Remarks

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

If Operand is a constant, DestImage and SourceImage must be the same type of image.

If Operand is an image, the image type of Operand depends on the image type of SourceImage, as follows:

If SourceImage is U8, Operand must be U8, I16, SGL, or RGB.

If SourceImage is I16 or SGL, Operand must be U8, I16, or SGL.

If SourceImage is RGB, Operand must be RGB or U8.

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.

This method is optimized for MMX.

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. DestImage can be one of the source images.

Example

Dim i As New CWIMAQImage

' Add a constant to an image in Viewer1.
' Store the result in i
CWIMAQVision1.AbsoluteDifference CWIMAQViewer1.Image, 50, i

' Find the absolute difference between the image in i and the image
' in Viewer1
' Do the operation inplace (store the result in i)
CWIMAQVision1.AbsoluteDifference CWIMAQViewer1.Image, i, i