The NI Vision Image Display does not support displaying transparency (for example, an alpha channel) using the Image Display control. However, it is possible to create transparency on a grayscale image by manipulating the RGB color planes.
This example will show you how to accomplish overlaying a semi-transparent color on top of a grayscale image. The example VI allows the user to select a color of the overlay, and then draw a Region of Interest (ROI) onto the image. Everywhere on the image outside of the will be covered in the semi-transparent color overlay.
Important note: This method implements the overlay by altering the image data. It should be used for display purposes only! If you need to perform analysis and processing on the image data, create a separate copy of the image before performing the method described below.
Description of the method used in this example:
- Start with an 8-bit unsigned image. Each pixel has a value between 0 (black) and 255 (white). At this point, you may want to create a copy of the image data in a separate IMAQ Image buffer that can be used for image processing/analysis since the data will be altered in step 2.
- Divide the image by 2 so that the image data is now mapped from 0-127. This sacrifices the most significant in the image data, so we lose some of the brightness resolution, but it gives us the upper 128 pixel values (128-255) of data to add the overlay information.
- Take the ROI and convert it to a mask.
- Use the mask to create a new image that is filled with a value of 128 everywhere outside of the ROI.
- Use the IMAQ OR operator to perform a bitwise OR between the divided down image pixels and the solid overlay. This essentially adds a constant 128 to every pixel in the image outside of the ROI.
- Create a custom user-defined color palette so that any pixel between 0-127 is displayed using the normal grayscale values multiplied by 2 (in order to return the image to display the image in its original brightness) and any pixel between 128-255 uses a custom color palette based on the color selected by the user.
- Apply the user-defined palette to the image display.

