Overview
This LabVIEW code converts a single image or a folder full of images from a 16-bit file format to an 8-bit file format by shifting and scaling pixel values to an 8-bit range. While this example is written to convert 16-bit images to 8-bit images, it can convert other data types to 8-bit images with little modification.
Description
Some viewers have difficulty displaying 16-bit IMAQ images, but most image viewers can display 8-bit images. The Example code opens saved 16-bit images, shifts the pixels so that the lowest valued pixel is the minimum value in the range, scales the pixels to fit on an 8-bit data range, and resaves the images in 8-bit format
Steps to Implement or Execute Code
Download and unzip the file called Convert 16-bit to 8-bit.zip attached to this post.
To convert a single image:
1. Open Convert 16-bit to 8-bit.lvproj
2. Open Image from 16-bit to 8-bit.vi.
3. Input the location of the image to be converted into the Image file path control, or browse for the image.
4. Select the desired output file type.
5. Set file options if desired.
6. Click run.
The file will be saved in the same directory as the original file, named <filename>_8.<filetype>.
To convert the contents of a folder:
1. Open Convert 16-bit to 8-bit.lvproj
2. Open Folder from 16-bit to 8-bit.vi.
3. Input the location of the file whose contents are to be converted into the File path of 16-bit images path control, or browse for the folder.
4. Select the desired output file type.
5. Input the location of the folder which will contain the converted images into the File path for 8-bit images control, or browse for the folder.
6. Set file options if desired.
7. Click run.
Files will be saved with the same filenames and the specified file type in the specified folder.