From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Create IMAQdx Palette (Binary, Rainbow, Gradient, etc)

Code and Documents

Attachment

Description:

This example uses two VIs to convert an 8-bit Gray image to a 32-bit Color image of a specified palette.

The main VI is just the IMAQdx Low-Level Grab from the shipped examples with an addition of the two other VIs. All VIs are in LabVIEW 2011, and they use the Vision Development Module 2011.

Instructions:

1) Set your IMAQdx camera to 8-bit mode ("Mono 8")

2) Pick the type of palette on the Block Diagram

3) Select the camera on the Front Panel

4) Run the VI

It is possible to do this with 16-bit images but will take additional programming. Difficulties with this can be seen here.

Block Diagram Steps:

CreateNewPalette.vi

1. Create cluster of the lookup table data based on the specified palette

2. Allocate the four IMAQ images in memory: The final image, and one for each color plane used in construction

3. Iterate through the array of the cluster containing the lookup table data. This will result in a lookup table array for each color plane; red, green, blue.

4. Bundle and output the data in a cluster for easier implementation in thetop level VI.

CreateNewPaletteBD.JPG

OverlayNewPalette.vi

1. Input cluster of data from CreateNewPalette.vi

2. Input image that will be changed from 8-bit gray to desired palette color

3. Apply the three new lookup tables to their own destination image copy created in CreateNewPalette.vi

4. Combine the resulting color planes into one final RGB 32-bit image

5. Output the resulting image for further manipulation

OverlayNewPalette.JPG


Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors