To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This example demonstrates how to convert image data type to an array and store them in TDMS file.
Description
Typically, images acquired using a LabVIEW application are stored as typical image formats such as PNG, JPEG and BMP. However, the question has arisen whether images can be stored in the TDMS file format. Although not natively supported by the TDMS file format, it is possible to convert an image data type to an array to be stored in TDMS.
The advantages to this approach include:
The TDMS file format is by no means recommended for all cases. Specifically, the drawback includes:
Essentially, the image is converted to a 2D array, which is then reformed into a 1D array. The width and data type of the pixels are stored as TDMS properties so that the image can be decoded from the TDMS file. The 1D array is written as TDMS data.
Initial comparison between 4 methods: TDMS, PNG, JPG, and BMP, has been completed. The benchmarks were completed with a 4000 x 4000 U8 image on two targets
Detailed results are shown below for 5 runs on each target.
In summary, it is clear that writing the image to TDMS is faster compared to other image format methods. The benchmarks include writing appropriate channel properties needed to decode the image.
Requirements
Steps to Implement or Execute Code
Additional Information or References
NI Snippet
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
Nice idea and incredibly fast. The 2014 VI runs into errors however - the TDMS file path is used as base path for the other 3 image files leading to an invalid path to save the images to. A simple StripPath before fixes it. No biggie.
There is a downside to this really fast saving of images: The resulting TDMS file takes up about 3 times the disk space as the uncompresses BMP file.