LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Greyscale image not displaying properly.

This is my first post here, so greetings!

 

I am working in LabView 11, and all updates are current.

 

I am trying to display a greyscale image with five shades varying from black to white. (The shade corresponds to a voltage, this is used to control a piece of optical equipment.)

 

The image is incorrectly displaying only the black shade and the next shade up (on an 8-bit color scale, it is showing only 0 and 63). I am using "draw unflattened pixmap", and I'm passing to it a 2D array of 8-bit numbers (0, 63, 127, 191, 255) and a Greyscal color table that I created. Each value in the 2-D array that is 63 or greater is drawn on the picture as a shade of 63. I've checked to make sure that the input array does have values that range up to 255.

 

The mysterious part is that I am using the exact same process in another step of my VI, and it is working perfectly. Same color table, same type of array, and I'm doing it several hundred times in a loop. It has never failed even once to produce the correct image.

 

I've attached my code, and two of the sub-VI's that I call from it. The main code is "Adaptive Optics Experiment". You won't be able to run it, as it requires a software development kit for a company called Andor for some of the sub-VI's, but maybe just by looking you can detect an issue. I've noted on the block diagram where the problem occurs, and where the same process seems to work fine. It's in the large stacked sequence structure; the working part is in frame 1, non-working in frame 2.

 

I've also attached an image of the final picture that shows only two shades.

 

Any suggestions would be greatly appreciated!

0 Kudos
Message 1 of 7
(3,470 Views)

Attached is the incorrectly displayed image that I mentioned in the original post.

0 Kudos
Message 2 of 7
(3,469 Views)

Hello mjpur

 

I am not a 100 percent sure but you may want to check your sub VI named "BuildPhaseMap.vi"

 

 

Derick Mathew
0 Kudos
Message 3 of 7
(3,441 Views)

Hi mjpur,

Suggestion: Please check this link for better coding in LabVIEW
http://www.ni.com/newsletter/51735/en/ 

-Coming to problem:you said in sequence:1 it is working and it's not in 2nd sequence and you mentioned the color tables are also same.
-Now the only terminal looks connected is with data terminal which is coming from BuildPhaseMap.vi
-Please check if the data coming from Build Phase Map is proper or not.

Thanks
uday
0 Kudos
Message 4 of 7
(3,428 Views)

Hi Uday,

 

Thank you for the link, that is very helpful.

 

I checked the output of BuildPhaseMap, and it looks the way it should. It produces a 2d array with all five possible values (0, 63, 127, 191, 255). The "Draw Unflattened Pixmap" sub-VI is getting the position of the "0" blocks correct (the fully black ones), so I know the array is being read by that sub-VI.

 

Mike

0 Kudos
Message 5 of 7
(3,377 Views)

Derick,

 

Thanks for the suggestion, but I've checked the output of that sub-VI and it is what I want it to be, a 2D array of 8-bit values in five discrete flavors (0, 63, 127, 191, 255). I ran the program with highlight execution and probes and checked it.

 

Mike

0 Kudos
Message 6 of 7
(3,376 Views)

Take another look at the help file for Draw Unflattened Pixmap VI under Draw 4 Bit pixmap.

 

 

It seems to me the output of your Build Phase Map is incorrect as it should only contain numbers that are indices of the grey scale. Hence it should output values between 0 and 4.

The color table input should contain the grey scale itself. The constant array you have should contain 0, 63, 127, 192, and 255.

 

You can test this by simply disconnecting your current BuildPhaseMap.vi and simply wiring up some constants to the Draw unflattened pixmap VI.

Jeff L
National Instruments
0 Kudos
Message 7 of 7
(3,335 Views)