GetPixel Method

NI Vision for Visual Basic

GetPixel Method

Syntax

CWIMAQVision.GetPixel SourceImage, Point, PixelValue

Return Type

Long

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

Purpose

Reads a pixel value from an image.

Remarks

Use this method with all image types.

Value is scalar when SourceImage is a U8, U16, I16, SGL, RGB32, or HSL32 image. Value is a two-element array when SourceImage is of type Complex. The first element of the array is the real part of the pixel value and the second element of the array is the imaginary part of the pixel value.

Value is a 1D array of four integer elements when SourceImage is of type RGBU64.

Parameters

SourceImage As CWIMAQImage

The source image.

Point As CWIMAQPoint

The coordinate of the pixel to read.

PixelValue As Variant

On return, the pixel value.

Example

Private Sub Run_Click()
    Dim point As New CWIMAQPoint
    Dim value
    
    ' Initialize the point alpha planes
    point.Initialize 10, 10
    
    ' Get the pixel from the image in Viewer1
    CWIMAQVision1.GetPixel CWIMAQViewer1.Image, point, value
    
    ' Set the pixel value at a different location
    ' into the image in Viewer1.
    point.Initialize 40, 40
    CWIMAQVision1.SetPixel CWIMAQViewer1.Image, point, value
End Sub