Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert 1-D array to 2-D array to get CWIMAQControlsLib.CWIMAQImage. (VB .NET)

I am using VB .NET. I have a 1-D array that represents a PNG image (loaded from database) and I want to convert this 1-D array into a 2-D array so I can call IMAQ.Images.Item(1).ArrayToImage(2-D_Array) to get a CWIMAQControlsLib.CWIMAQImage.
Is there any way I can do this? Please help. Thanks.
0 Kudos
Message 1 of 5
(4,072 Views)

John123,

I am not too familier with the format of a PNG.  My guess is that your 1-D array is basically a 2-D array with each row lined up end to end.  If this is the case you should be able to create a 2-D array in VB.NET and then copy each row of pixels into the 2-D array.

For example...

Lets say your image is 5 pixels by 4 pixels.

PNG 1-D Array:  1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20

2-D Array:
1,2,3,4,5
6,7,8,9,10
11,12,13,14,15
16,17,18,19,20

Good Luck,
Lorne Hengst
Application Engineer
National Instruments

0 Kudos
Message 2 of 5
(4,065 Views)
The image is 640 x 480, but the number of elments in the 1d array does not equal to 640 * 480,  not equal to 640 * 480 * n, here n is a integer. There might be some header information, but I don't know the format. Thanks for your replay.
0 Kudos
Message 3 of 5
(4,063 Views)

John,

Your going to have to read up on the png format and determine how the data in the format is structured so you can convert it properly.

Lorne Hengst
Application Engineer
National Instruments

0 Kudos
Message 4 of 5
(4,047 Views)
John123 -

You could also write the array out to file as a .png file and use CWIMAQVision.ReadFile to read it in an image.

Greg Stoll
Vision R&D
National Instruments

Greg Stoll
LabVIEW R&D
0 Kudos
Message 5 of 5
(4,037 Views)