Showing results for 
Search instead for 
Did you mean: 

Initializing Arrays, Draw Unflatten Pixmap

Hi all.


I have a peice of code that


- Reads an 8-bit grayscale image. Labview reports its depth as 8.

- Extracts the 1d array

- Repackages as a 2d array

- Draws using unflatten pixmap

(And this works fine.)



- Initializes two arrays of 8-bit data, one array to one value, the other to another, the same size as the image.

- Repackages as a 2d array

- Draws using unflatten pixmap


However this doesn't work, the array is always initilized to 0; or at least, the images appear black (0).


What can be wrong?


(The above is for testing another piece of code).



0 Kudos
Message 1 of 6

Sorry hit the wrong button before adding the attachments.

Download All
0 Kudos
Message 2 of 6

After some more debugging -


strangely, if I initialize instead 2D array (and therefore get rid of the 1D-2D block), it all works fine.




0 Kudos
Message 3 of 6

Sorry the .vi attached for the working case was wrong.






0 Kudos
Message 4 of 6

It's funny to watch people carry on conversations in these threads with themselves.  I can laugh because i have done it.  Smiley Very Happy

LabVIEW 2017
LabVIEW Programming
0 Kudos
Message 5 of 6

Hello Gunter,


The issue is not the reshape operation, but the multiply you do before generating the 1D array- your image of dimensions 200x201 requires ~40000 elements, which overflows the range of the I16 used to represent the bounds of the image.  You then attempt to initialize arrays of <0 elements, which actually gives you an empty array. This is then reshaped to 200x201 and the empty elements are filled with the default value of zero.


Be careful when doing operations like this on minimally-represented numbers! It's relatively easy to overflow the bounds of 8- and 16-bit integers doing standard operations on reasonable-seeming values if you're not cautious. Those coercion dots (red) on your diagram are a hint, and try debugging using execution highlighting, etc. - as soon as you see that ~-32000 zip across the screen, you'd know what was happening.


Best Regards,

Tom L.
0 Kudos
Message 6 of 6