Visualization and Imaging

Publish Date: Jul 31, 2009 | 1 Ratings | 5.00 out of 5 |  PDF

Visualization and Imaging

The NI LabVIEW development environment and the G programming language provide an excellent platform for visualization-intensive applications, which are common in scientific computing. LabVIEW offers different tools, from simple line, column, or scatter graphs; to a wide variety of specialized plots (Smith, Bode, Nichols, Nyquist, radar, polar, and so on); to 2D graphs and advanced 3D surface/mesh graphs and plots. Also, through the use of toolkits and modules, you can easily add more capabilities to LabVIEW. For example, you add process symbols when you use the LabVIEW Datalogging and Supervisory Control Module. Additionally, with the 3D Picture Control Toolkit, you add support of OpenGL-based graphics and VRML files. And by using the LabVIEW Control Design and Simulation Toolkit and the NI Vision Development Module, you add yet more visualization tools to the standard set of indicators, controls, and functions included in LabVIEW.

This summary of some of the most commonly used visualization options in LabVIEW presents both basic and sophisticated tools. Considering that G is a programming language, and you can add external functions and libraries as needed, the visualization capabilities of LabVIEW are almost unlimited.

Controls and Indicators

A wide variety of front panel controls and indicators are available in LabVIEW, including numeric controls and indicators such as slides and knobs; graphs; charts; Boolean controls; and indicators such as buttons and switches, strings, paths, arrays, clusters, listboxes, tree controls, tables, ring controls, enumerated type controls, containers, and much more. Also, you can use XControls to design and create complex controls and indicators in LabVIEW.

Figure 1. Numeric and Boolean Indicators and Controls in LabVIEW

Also, LabVIEW features indicators and controls for matrices, arrays, and clusters.

 

Figure 2. Matrix, Array, and Cluster Indicators/Controls

You can customize most of the controls and indicators previously listed using the “Customized Control” option in LabVIEW. As an alternative, you can use XControls to design and create complex controls and indicators in LabVIEW. When you create an XControl, you combine built-in LabVIEW controls and indicators to take advantage of the combined functionality of the built-in LabVIEW controls and indicators.

Figure 3. XControl Developed in LabVIEW

Unlike custom controls, which you use to create custom user interface components that vary cosmetically from built-in LabVIEW controls and indicators, XControls have dynamic run-time and edit-time behavior that is defined by VIs running in the background. When you use an XControl in a VI, the block diagram for that VI is simplified because the XControl includes the behavior of the control. When you create an XControl, you use the LabVIEW Project Explorer window to edit the XControl library. In Figure 3, a thermometer indicator and a pointer slide are used in an XControl so they can both work in Celsius and Fahrenheit scales, as selected by the check marks shown in the figure.

Image Navigator

If you use the LabVIEW Datalogging and Supervisory Control (DSC) Module, you have extensive graphic symbols and objects for creating process monitoring and control-oriented applications such as SCADA systems, operator interfaces (OIs), graphical user interfaces (GUI), and so on. These are available through the Image Navigator included with LabVIEW DSC.

Figure 4. LabVIEW Datalogging and Supervisory Control (DSC) Module Image Navigator 

Graphs and Charts 

After you acquire or generate data, or if data is readily available in a file or database, you can use a graph or chart to display data in a graphical form.

Graphs and charts differ in the way they display and update data. VIs with a graph usually collect the data in an array and then plot the data to the graph. You typically use graphs with fast processors that acquire data continuously, but you can also use them with data already saved in a file or database. The waveform graph, which displays one or more plots of evenly sampled measurements, plots only single-valued functions, as in y = f(x), with points evenly distributed along the x-axis, such as acquired time-varying waveforms.

In contrast, a chart appends new data points to those points already in the display to create a history. On a chart, you can see the current reading or measurement in context with data previously acquired. When more data points are added than can be displayed on the chart, the chart scrolls so that new points are added to the right side of the chart while old points disappear to the left. You typically use a chart with slow processes in which only a few data points per second are added to the plot. The waveform chart is a special type of numeric indicator that displays one or more plots of data typically acquired at a constant rate.

Figure 5. Waveform Graph, Waveform Chart, and XY Graph

The XY graph is a general-purpose, Cartesian graphing object that plots multivalued functions, such as circular shapes or waveforms with a varying time base. The XY graph displays any set of points, evenly sampled or not. You also can display Nyquist planes, Nichols planes, S planes, and Z planes on the XY graph. Lines and labels on these planes are the same color as the Cartesian lines, and you cannot modify the plane label font. You can also use the x-y graph to plot Z and S planes and Nyquist and Nichols plots.

Figure 6. Intensity Chart

You can use the LabVIEW intensity graph and chart to display 3D data on a 2D plot by placing blocks of color on a Cartesian plane. For example, you can use an intensity graph or chart to display patterned data, such as temperature patterns and terrain, where the magnitude represents altitude. The intensity graph and chart accept a 3D array of numbers. Each number in the array represents a specific color. The indexes of the elements in the 2D array set the plot locations for the colors. The use of these charts/graphs is almost unlimited.

For example, you can plot a fractal using an intensity graph (see Figure 7).

Figure 7. A Fractal Plotted with an Intensity Graph

LabVIEW also offers the digital waveform graph to display digital data, especially when you work with timing diagrams or logic analyzers. The digital waveform graph accepts the digital waveform data type, the digital data type, and an array of those data types as inputs. By default, the digital waveform graph displays data as digital lines and buses in the plot area. You can customize the digital waveform graph to display digital buses, digital lines, or a combination of both. If you wire an array of digital data where each array element represents a bus, the digital waveform graph plots each element of the array as a different line in the order that the array elements draw to the graph.

Figure 8. Digital Waveform Chart

The mixed-signal graph, which can display both analog and digital data, works with all data types accepted by waveform, XY, and digital waveform graphs. A mixed-signal graph may have multiple plot areas. A given plot area can display only digital or analog plots, not both. The plot area is where LabVIEW draws the data on the graph. The mixed-signal graph automatically creates plot areas when necessary to accommodate analog and digital data. When you add multiple plot areas to a mixed-signal graph, each plot area has its own y-scale. All of the plot areas share a common x-scale, allowing for the comparison of multiple signals of digital and analog data.

Figure 9. A Mixed-Signal Graph

The 3D graphs are included in the LabVIEW Full and Professional development systems. These are useful for many real-world data sets, such as the temperature distribution on a surface or a joint time-frequency analysis, where you need to visualize data in three dimensions. With the 3D graphs, you can visualize 3D data and alter the way that data appears by modifying the 3D graph properties.

Figure 10. 3D Graphs

With LabVIEW, you also can use a combination of different graphs, charts, and plots in one common user interface. For example, as shown in Figure 11, you can use an intensity graph and a 3D surface graph simultaneously to display the solution to the heat equation. Also, you can use indicators as controls for capturing input data. In Figure 11, the intensity graph is also used as an input (you can interactively drag and drop the hot point), while the 3D surface graph displays the temperature distribution.

Figure 11. Heat Equation Plotting by Combining an Intensity Graph and a 3D Surface Graph

For control design and similar applications, such common plots as zero pole, root locus, Nichols, Bode, and Nyquist are also available in LabVIEW with the LabVIEW Control Design and Simulation Module.

Figure 12. Bode Plot

Figure 13. Control Design Plots: Nichols, Nyquist, Zero-Pole Map, Root Locus

You use the control design indicators to display Nichols, Nyquist, pole-zero mapping, and root-locus plots. With the indicators on the CD Plot palette, you can display these plots on the front panel of a VI you create. Use the indicators on the CD Dialog Plot palette to display these plots in the dialog boxes you create. These dialog plot indicators are specifically for use in dialog boxes. Also, you can create these indicators from the block diagram by using the CD Nichols VI, the CD Nyquist VI, the CD Pole-Zero Map VI, and the CD Root Locus with Gain VI.

Each control design plot indicator can display either the grid unique to that plot or the Cartesian grid. By default, when you place a control design plot indicator on the front panel, the visible grid is the grid unique to that plot. To enable and disable this grid, right-click the plot indicator on the block diagram and select Show Grid from the shortcut menu. Similarly, to enable and disable the Cartesian grid, right-click the plot indicator on the block diagram and select Show Cartesian Grid from the shortcut menu.

You can build specialized graphs such as spectrograms using some of the same tools discussed previously. Also, you can edit and modify most indicators and controls in LabVIEW to meet your specific application requirements.

Figure 14. Time-Domain Signal and Its Spectrogram

The Vision Development Module for image processing applications features several visualization tools, including the capabilities to display and analyze pictures, images, and video in real time or offline (JPG, PNG, TIFF files) using color or black and white cameras, both analog and digital. You can display and analyze images from infrared cameras in real time.

Figure 15. Matrix Code, Infrared, Color, and Grayscale Images Displayed by the Vision Development Module

For example, using the Vision Development Module, you can capture images directly from a standard microscope or an atomic force microscope (ATM) and make measurements directly on the image.

The following example features an image of nanotubes (100 µm scale) for which the Vision Development Module is used to detect edges between nanotubes and measure the distance between them.

Figure 16. Edge Detection on an Aligned Nanotubes Image

Other Tools for Creating 3D Graphical Representations

In addition to the above graphs, plots, and charts, LabVIEW features other tools for creating pictures and 3D graphical representations of objects.

First, the picture indicator includes a set of drawing instructions for displaying pictures that can contain lines, circles, text, and other types of graphic shapes. Because you have pixel-level control over the picture indicator, you can create nearly any graphics object. Use the picture indicator and the graphics VIs instead of a graphics application to create, modify, and view graphics in LabVIEW. Examples of these “pictures” are the Smith, polar min/max, and radar plots, as well as any custom designed “picture.”

Figure 17. Smith, Polar, and Radar Picture Plots

Second, the 3D picture control displays graphical representations of 3D objects. It supports the VRML, STL, and ASE formats. A 3D scene is a 3D object or a collection of 3D objects that you can view in the 3D picture control or in a separate scene window. As you design a 3D scene, you can generate multiple 3D objects and specify their orientation, appearance, and relationship to other objects within the 3D scene. You can set characteristics of the 3D scene such as the style and location of a light source and how a user-controlled camera interacts with the 3D scene.

Figure 18. Simple 3D Scenes Using the 3D Picture Control Functions

You can continuously update the 3D scene to display live or continuously changing 3D data. For this, you place the 3D scene in a loop such as a for loop or while loop, but place the 3D picture control terminal outside the loop. The data you write to the 3D picture control updates with each iteration of the loop. You can either create more features in LabVIEW or add more features via external libraries or software packages. In addition, you can connect some of these external libraries to LabVIEW via the Call External Function VI, TCP port, or ActiveX controls, or you can use specific VIs created for this purpose.

For example, to draw a serial robot arm in LabVIEW, which can be animated in real time during simulation or while an actual robot arm physically moves (the robot arm can be connected to the PC via a data acquisition device; digital interfaces such as RS232, RS422, RS485, CAN, and TCP/IP; and so on). In this specific example, simulated data or real-world signals are displaying and dynamically animating a serial robot arm. There are several options for doing this − two of them using native LabVIEW code and a third one using an external application (NI INSIGHT).

In Figure 19 (from left to right), the first example uses the 2D picture indicator and functions; the second example uses the 3D Picture Control Toolkit; and the third example uses an external application, NI INSIGHT and its respective VIs, to connect the 3D robot arm to LabVIEW. In all three cases, you can control (animate) the robot arms programmatically (simulated mode) with real-world signals (using the PC’s digital ports or a data acquisition device) or manually by using a joystick or front panel controls. All three examples are available in LabVIEW and NI INSIGHT.

Figure 19. Animated Robot Arm with the LabVIEW Picture VIs, 3D Picture Control Toolkit, and NI INSIGHT

3D Picture Control Toolkit Example

As a simple example, draw a Torus using the 3D Picture Control Toolkit (now also included with the LabVIEW Control Design and Simulation Module). Execute the following steps in the LabVIEW program:

Define the object:

  • Build the model − In this case, draw a Torus using the “Build Toroid.vi,” with an inner radius of 1, outer radius of 2, and the number of faces (20). Also, use the “Create Model.vi” to actually create the model.
  • Build the materials − Using the “Add Material.vi,” select the color of the object (green), the color of the reflection or specular (gray), and the shine factor (0.5).
  • Build the transformations − Using the “Create Transform.vi,” define the translation, rotation axis, and rotation angle (90).
  • Build the object − With all the previous steps defined, create the model using the “Add Model.vi.. The model is a “Torus” in this example.
  • Build the camera − Using the “Create Camera.vi” and “Camera Look at.vi,” define the projection (perspective) and the camera position (0,0).
  • Build the light − Using the “Create Positional Light.vi,” create the light to be used in the scene. Define the specular color (gray), the diffuse color (gray), and the ambient color (black). Also define the position of the light (-50, 50, 120).
  • Combine the object, camera, and light into a scene − Using the “Render Scene.vi,” combine the results of the previous steps in preparation for rendering the scene.
  • Render the scene − Using the “Draw Scene.vi” and a picture indicator, render the final scene.

The following G code replicates all the steps listed above:

Figure 20. G Code for Rendering a Torus Using the 3D Picture Control Toolkit

The rendered object (Torus) looks like this:

Figure 21. Rendering of a Torus Using the 3D Picture Control Toolkit

A real-world use of a Torus plot is a plasma diagnostic (and control) system for a tokamak (fusion nuclear reactor), where a “dynamic” Torus is plotted with real-time data (currents) obtained from the probes installed in the reactor and overlaid with a picture of the cross-section of the actual Torus inside the reactor. Figure 22 shows the combination of a picture with a rendered Torus, which is constructed with real-time data from the actual current measurements.

Figure 22. Rendering of a “Dynamic” Torus for Plasma Diagnostics

A fourth option is to use a third-party software tool, such as RoboWorks (from Newtonian), which provides a live interface to LabVIEW and allows real-time data exchange between the two. The communication mechanism used is based on TCP/IP and called RoboTalk, also from Newtonian.

Figure 23. Animated Robot Arm with LabVIEW and RoboWorks

Finally, you can use the many LabVIEW MathScript plots and functions to easily expand LabVIEW's visualization capabilities.

Figure 24. LabVIEW MathScript Plot

You can use external tools such as DirectX, Microsoft Media Player, OpenGL libraries, and similar tools with LabVIEW for multimedia-type applications for which sound, video, and images are combined and used in highly interactive applications. This type of tool is commonly used for technical training, distance learning, and remote labs applications.

Related Links

Scientific Computing with Graphical System Design

Scientific Computing with NI LabVIEW

Multicore Programming

Introduction to G Programming

Introduction to Curve Fitting

Statistical Analysis

Scripting Languages and NI LabVIEW

 

Back to Top

Bookmark & Share

Ratings

Rate this document

Answered Your Question?
Yes No

Submit