Example Code

Save an image as binary file and convert the loaded image back to a LabVIEW picture

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This example demonstrates how to save an image as binary file and how to load the file and convert it back into a LabVIEW picture.

 

Description

This example contains two VIs.

The first VI shows how to save an LabVIEW picture as binary image. To do so, a LabVIEW picture is converted into a pixelmap which provides a 2D array of U32 interger. This 2D array is saved as binary file.

The second VI loads the binary file and convert it back into a LabVIEW picture. The user select the file which he wants to load. LabVIEW reads the file as binary file and provides the data as 1D array of pixel values. The 1D array is reshaped into 2D array and converted into a LabVIEW picture, so that it can be shown on the Front Panel.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Download and open the attached ZIP-file
  2. Open and run Save Image As Binary File.vi
  3. Open and run Load Image From Binary File.vi

 

Additional Information or References

Save Image As Binary File - Front Panel.png

 

Save Image As Binary File - Block Diagram.png

 

Load Image From Binary File - Front Panel.png

 

Load Image From Binary File - Block Diagram.png

 

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**
Owen.S
Applications Engineer
National Instruments

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

Comments
EoinBolger93
Member
Member
on

IMAQ and Adjsent VI not included In down Load Could you please attach these files ??

mini09
Active Participant
Active Participant
on

Dear EoinBolger92,

Install NI IMAQ toolkits.

EoinBolger93
Member
Member
on

Thanks didnt realise

seniya
Member
Member
on

The file vi works ok. Could you please provide an example of extracting and saving multiple images from the binary file.