Example Code

Archived: Convert Image to 8-bits

Code and Documents

Attachment

Overview


This document has been archived and is no longer updated by National Instruments.

There are some external viewers available that do not display 16-bit IMAQ Images correctly. Vision 7.1 or later 16-bit PNG files work with many viewers, but some don't handle 16-bit images correctly. External viewers will not display complex images correctly either. These examples illustrate how to convert images to 8-bits, which all viewers work with because it's more standard.

The first example converts a directory of 16-bit images to 8-bit images. It determines the dynamic range of the 16-bit image and maps the pixels to 0-255 range.  This example is written in Visual Basic.

The second example converts three 16-bit images to their 8-bit version and then combines them into an RGB image. This example is written in Visual Basic.

The third example converts a directory of 16-bit images to 8-bit images. It determines the dynamic range of the 16-bit image and maps the pixels to 0-255 range.  

The fourth example converts a complex IMAQ image into an 8-bit image so the display will look the same in other viewers. Complex images can only be saved in AIPD format, a proprietary National Instruments format. Since other viewers don't support AIPD, it's necessary to convert complex images to 8-bits if you need to display the image in other viewers.

The fifth example is an executable that doesn't require Vision, or other ADEs to convert a 16-bit image to 8-bits.

 

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

Contributors