Example Code

Using the 3D Picture Control 'Create Height Field VI' to convert a 2D image into a 3D textured heightmap

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 VI is an example of using the 3D picture control and the Create Height Field VI to convert an image into a 3D height map.

 

Description 

This VI is an example of using the 3D picture control and the Create Height Field VI to convert an image into a 3D height map.

The original image is analyzed and each pixel is converted to a height based on its colour: pure white will be the highest point on the map, pure black the lowest.

This data is then passed into the Create Height Field VI to create a height map of the original image.

 

The object and camera are positioned so the object is clearly visible when the program starts

 

A series of textures are also loaded and depending on a front panel control, different textures can be applied to the object while the program is running.

 

Requirements

  • LabVIEW 2012(or compatible)

 

Steps to Implement or Execute Code

  1. Download and run the VI,
  2. Select different textures to load in Texture Control.

 

Additional Information or References

 

Front Panel

3d heightmap.JPGtc.JPG

 

VI Snippet

1.png

 

The texture is applied on ever iteration of the loop, this is just to keep the example simple but in a larger application it would be worth some additional code to only apply a texture when a new one has been selected.

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

------
John.P | Certified LabVIEW Architect | NI Alliance Member

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

Comments
JCC_(SK)
Active Participant
Active Participant
on

Nice example. Thank you.

You could do array division much easier:

array division.png