03-23-2009 03:51 PM
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
Solved! Go to Solution.
03-24-2009 02:32 PM
03-24-2009 03:49 PM - edited 03-24-2009 03:52 PM
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!
03-24-2009 07:45 PM
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.
03-25-2009 08:49 AM
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
03-25-2009 07:16 PM
03-26-2009 07:43 AM
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.
03-26-2009 02:07 PM
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)
03-30-2009 01:20 PM
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
03-31-2009 09:24 AM - edited 03-31-2009 09:24 AM
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.