LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to overlay a partially transparent image (RGB user created) on an grab acquired image (I16 Grayscale) session in a while loop?

Solved!
Go to solution

Hello,

I am attempting to overlay a partially transparent Alpha,RGB image, which I have already created through some pixel manipulation, onto an I16 grayscale image.  The I16 image is being grab acquired and the RGB is from a file location.  So, my issue is that when I attempt to add (IMAQ) the images together, the IMAQ add.vi gives me an incompatible image type error.  I understand these are differing image types; but, I need to find a work-a-round in order to get the color information on the grayscale information during a frame grab session.  This frame grab session is in a while loop so it runs a bit slow which is okay.

 

I have already overlayed the RGB on an I16 image.  However, both images in this instance is called from a file location and not from a grab session.  Now, I need a new vi which will overlay the created file on the grab session images.

 

If any addition information is needed, please feel free to ask for it.  This situation is a bit difficult to describe clearly.

 

Thank you for your help,

David Fox

0 Kudos
Message 1 of 27
(6,428 Views)
By the way, I am not looking for someone to write a vi for me.  All I am interested in is the algorithm and a general idea of how to accomplish this.
0 Kudos
Message 2 of 27
(6,405 Views)

Hey dwfox,

 

Would it be possible for you to attach your images for us? If it is, it would be a lot easier to visualize your task.

 

Also, is your image in your grab session an I16 grayscale? If so, there should really be no difference in an I16 from a file and an I16 from an acquisition.

 

Thanks!

Message Edited by Chris_VH on 03-24-2009 03:52 PM
Chris Van Horn
Applications Engineer
0 Kudos
Message 3 of 27
(6,397 Views)

It has been a while since I used alpha channels but if my memory holds, for each R,B,G, you can do a weighted average to get the new pixels value.   When doing a RGB with a I16 Grey Scale this could be a little awkward since you have 8 bit depth in one image (8 for each color channel, and 16 for the grey scale).  I would guess that for each new pixel you could get

Red' = (alpha)*Red+(1-Alpha)*(I16/2^8)

Green'=(alpha)*Green+(1-Alpha)*(I16/2^8)

Blue'=(alpha)*Blue+(1-Alpha)*(I16/2^8)

 

Where alpha is a weight 0.0 to 1.0 of the relative transparency of teh RGB image.  The /2^8 is to rescale the I16 to an 8bit scale, you might want to use a scale the doesnt comprimise the dynamic range as much I.E. Fine the min and max valuse and rescalr to 8-bits over the used dynamic range of the 16bit image.

 

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 4 of 27
(6,386 Views)

Thank you all for you two for you replies.  Hopefully my attachments will help.  I have included the two vi's, a zip file with my images, and a RGB image of what I am attempting (in the zip folder, remove this file before running the vi's).  The output of my program should have the same results as the RGB file except that my program should have 'live' background images.  If you have any more questions, please let me know.  Of course, the main program here is the NI_Overlay_Feed.vi and the merge is the sub.

 

Thank you

dwfox

Download All
0 Kudos
Message 5 of 27
(6,376 Views)
dwfox1977, you could try using the IMAQ Cast Image VI to cast the greyscale image to RGB then add them.
Jeff | LabVIEW Software Engineer
0 Kudos
Message 6 of 27
(6,360 Views)

Jeff,

I can not reformat the images into other scales, unfortunately.  We need to preserve the grayscales throughout the processes.  The most important information is the information contained as intensity values in the grayscale regions.  What I am doing with the RGB is like 'icing on the cake' and mearly adds visual value for presentations and customers.  Furthermore, the RGB, in the end, will only have a limited transparency.

0 Kudos
Message 7 of 27
(6,356 Views)

Since you only have 24 bits to display RGB you will have to eithter do some bit manipulation or some other work around.

 

Option 1:

 

Make your RGB using the 5 bits of R,G,B as your 16 bit number and highlight the color with the remaining 3 bits.  Not sure how this will turnout?

 

Oprion 2: Make a floating window with a picture control the same size as the imaq control, float this window over the imaq control, hine toolbar, title bar, scroll bars ... and set the transparency of the window to yield the desired effect (work but not too elegant)

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 8 of 27
(6,351 Views)

Well, thank you for your input.  Unfortunately, I need something that is elegant.  Hopefully, someone out there is able to assist me in my adventure here.

 

So, I will state the issue again.

I need a partial RGB overlay (accomplished) to overlay on a grayscale 'live' feed and display the result.  My code is attached to the thread above.  Therefore, I need to slightly modify the coding in order for my image to be displayed and the mission will be accomplished.  If anyone is able to help, fantastic!  And thanks for the help you all have given thus far.

 

dwfox

0 Kudos
Message 9 of 27
(6,303 Views)

Take a look at the attached and see if it does what you want.  It uses the overlay feature to overlay the RGB on top of the Grayscale image.  I turn on transparency by setting the upper byte of the RGB array to one and then feeding this into the Bitmap Overlay function.  Then I merge the overlay with the grayscale image to get the final result.

 

You'll have to get in the block diagram and point to your image files.

Message Edited by rpursley8 on 03-31-2009 10:24 AM
Randall Pursley
Message 10 of 27
(6,305 Views)