ImageToArray Method

NI Vision for Visual Basic

ImageToArray Method

Syntax

CWIMAQImage.ImageToArray [Left] [, Top] [, Width] [, Height]

Return Type

Variant

The output array of image data.

Purpose

Extracts a pixel array from an image.

Remarks

Specify the portion of the image to extract using the Left, Top, Width, and Height optional parameters. If you do not specify a rectangle, the method extracts the entire image.

If the image type is cwimaqImageTypeComplex, the output array is a 1D array of two elements. The first element is a 2D array containing the real plane, and the second element is a 2D array containing the imaginary plane.

If the image type is cwimaqImageTypeRGBU64, the output array is a 2D array of 1D arrays with 4 elements (the Red, Green, Blue, and Alpha channels of each pixel).

Parameters

Left As Variant

[Optional] The left boundary of the extraction rectangle. The default value is 0.

Top As Variant

[Optional] The top boundary of the extraction rectangle. The default value is 0.

Width As Variant

[Optional] The width of the extraction rectangle. The default value is the width of the image.

Height As Variant

[Optional] The height of the extraction rectangle. The default value is the height of the image.

Example

' Convert the entire image to an array

Dim a As Variant
a = CWIMAQViewer1.Image.ImageToArray

' Convert a portion of the image to an array

Dim b As Variant
b = CWIMAQViewer1.Image.ImageToArray(10,10,100,100)

Image To Array Example