LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save an image with partial transparency

There appears to be no way to preserve alpha channel information when saving an image out of labview, even when using the IMAQ vision functions. That is to say, you can create a partially transparent image using labview, but you can't save it to disk. Is this correct?


global variables make robots angry


0 Kudos
Message 1 of 5
(5,095 Views)

I think there is aoption save Jpeg image, try with that.

 

Regards

Visuman

0 Kudos
Message 2 of 5
(5,076 Views)
Can you post an example VI that highlights your issue? I am not sure what you mean when you say that LabVIEW cannot save images.
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 3 of 5
(5,065 Views)

Hi Root Canal,

 

I found this article that talks about the way that LabVIEW deals with information in the alpha channel when reading images: Which Image File Formats are Capable of Transparency in LabVIEW? 

 

Your best bet is obviously going to be a PNG file.  However, I have not had time to test out how the image files would look when opened up in another image viewer.  Specifically, what program are you trying to use to open this? 

 

This article also hints that LabVIEW (without IMAQ) is also able to utilize that alpha channel: What is the Difference Between LabVIEW and IMAQ support for PNG Images?  

 

Please go ahead and post back after reading these articles, and I'll see what I can do in terms of testing out the transparency of images in third party viewers. 

 

Cheers, 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 4 of 5
(5,044 Views)

The issue boiled down to bad documentation. LabVIEW is cool, but I really can’t wrap my head around how, given the very limited amount of documentation, so much of it could contain goofy mistakes. The documentation says that LabVIEW can’t handle a 32-bit image, and that it can only render transparency as a binary mask.

 

Attached is a VI that demonstrates how to create partial transparency in LabVIEW by building a 32-bit image with an alpha channel. LabVIEW has no problem saving it out as a PNG. You can’t display it properly with the picture indicator, but you can display it properly with the 3d picture control. You have to ignore the documentation and switch the image bit depth value to 32 and order the image data as groups of 4 bytes, alpha, red, green, blue for each pixel.

 

32 bit with alpha channel small.png

 

Also, if you create a binary picture mask to be used with a picture indictor, you need to add an extra column of bytes for no identifiable reason. You’ll find that when LabVIEW reads in a PNG with an alpha channel, it reads it in properly and creates a binary mask. You can save it out properly and alpha channel info is preserved. The mask will be larger than expected because of the weird extra column of bytes that isn’t mentioned in the documentation. For instance, if you load a 600 x 400 PNG with an alpha channel, the mask will be 30400 bytes long instead of 30000 bytes that would be expected if the description of how the binary mask works was right.

 

Please note that there are two separate data structures (the 32-bit image data with an alpha channel and the binary mask with the weird extra column) that are described incorrectly in the documentation for all of the picture function help pages. Note that there are several lines in each affected help page that need to be corrected.

 

 

I like LabVIEW because it’s great for communicating with NI hardware, it’s easy to do parallel computing and it’s super easy to make a nice GUI. I’ve used LabVIEW to write real-time target tracking software that works on a wide range of targets in real video and I’ve used to it write a real-time 3D simulation using real imagery and real video including ground imagery, transparent cloud imagery and real video of explosions. So, even though the function libraries are not terribly robust, I know that LabVIEW has a good deal of potential as a platform for serious programming work. I only started using LabVIEW less than two years ago, so that should tell you that LabVIEW is fairly intuitive to use.

 

However, I’m a little disappointed and frustrated with it because I keep getting burned by poor documentation and silly bugs that eat up programming time. LabVIEW is expensive software, and while the function libraries are nice, they are somewhat limited. I think that National Instruments should either offer much more functionality or do a better job documenting and debugging the existing function libraries (of add-ons and toolkits, too) in order to justify the cost of LabVIEW software.

Message Edited by Root Canal on 11-02-2009 05:33 PM
Message Edited by Root Canal on 11-02-2009 05:35 PM
Message Edited by Root Canal on 11-02-2009 05:37 PM

global variables make robots angry


Message 5 of 5
(5,008 Views)