Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

transparent background

Hello,

I use the IMAQ vis in labview to cut out from a tif image an object that appears on a grey spotty background and paste the object on a "clean" background. Currently the "clean" background is white. The image is saved as a tif file and read in photoshop where the object is rotated to match a predefined orientation. The problem is that the white background also rotates which is not desirable. When the manipulation is done entirely in photoshop (cutout + pasting + rotation), the clean background and the object are placed in different layers. Is there a way to do this in Labview, that is to create an image where the background and the object would be read by photoshop as being in different layers? Alternatively, can the clean background be  made transparent in labview. I understand the png  files  can have a transparent background. How can I specify that the background is transparent instead of white?

Thank you for your help

Jean-Michel Maarek
0 Kudos
Message 1 of 4
(4,489 Views)
Hi Jean-Michel,

Is there a specific reason that you are doing the rotation in Photoshop?  You can actually use the IMAQ Rotate VI to rotate an image by an arbitrary angle.  However, if you still need to manipulate the image in Photoshop, it may be possible.  To my knowledge, the .png file format does not support multi-layered images, but it does allow for transparency.  To use transparency, the easiest way would probably be to use the standard LabVIEW picture functions.  You can find a good description and some sample code in this KnowledgeBase article:

http://digital.ni.com/public.nsf/allkb/00736861C29ADFB786256D120079D119?OpenDocument
Regards,
Brandon M.
Applications Engineer
National Instruments
Message 2 of 4
(4,472 Views)
Hi Brandon,

thank you. I am wondering if you know whether the vi to write png files (write PNG file.vi) preserves the mask information.

In the attached code, the source image (a .tif file zipped for posting) is read with the IMAQ read file function. The transparency information is added by comparison to a threshold. The picture appears thresholded on the front panel but when the png file is saved, the transparency information appears to have disappeared. When I place the saved image on the front panel or look at it with the Firefox browser, I only see a copy of the original image without transparency?

Thank you for your reply.

Jean-Michel Maarek
Download All
0 Kudos
Message 3 of 4
(4,458 Views)
Mask can't be saved.  It's just for display.  Same in other languages.  To save mask info, convert it to alpha channel, convert the image to 32 bit (ARGB), and save the image to a tif or png file.  When you open the tif file in Photoshop, you'll see the transparence effect. 
 
LabVIEW doesn't support alpha channel display in picture control, while read the ARGB image, you have to convert the alpha channel back to mask for display with picture control.
 
"Save Image with Transparency" demonstrates how to create alpha channel.
George Zou
0 Kudos
Message 4 of 4
(4,407 Views)