17.12.2018 Views

Image Acquisitionand Proces

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4<br />

Displaying <strong>Image</strong>s<br />

Although not always necessary, displaying acquired and processed images to the<br />

user is often desirable. If your application calls for the user to be able to review<br />

image data, it is wise to consider performance and user interface designs very<br />

seriously. Your Þrst question should be, “does my application really call for image<br />

data display?” Although we all like to “show off” our programming expertise, and<br />

there is no better way than to show the users (read: managers) the before-and-after<br />

data, displaying images can have much more detrimental effects to system performance<br />

than traditional DAQ systems.<br />

First, image data can often contain much more information than simple DAQ<br />

data — a voltage trace with respect to time may be only an array of a few thousand<br />

doubles, whereas a similar application acquiring images over time could easily Þll<br />

up your RAM (e.g., a 1024 ¥ 768 32-bit image is approximately 3 Mb). Similarly,<br />

image data generally contains more “background” data than tradition methods,<br />

simply due to its two-dimensional nature.<br />

Second, displaying any data on your front panel will take time and memory.<br />

Using a multithreaded version of LabVIEW, whenever you wire data to an indicator<br />

(numeric, string, Boolean, image, etc.) the execution thread is stopped, and the<br />

system switches to the user interface (UI) thread. The UI thread’s copy of the<br />

indicator’s data is then updated (this is generally called the operate data), and if the<br />

panel is open, it is redrawn. Then the data is sent back down to the execution thread,<br />

but in order to do this, it is Þrst sent to a protected area of memory called the transfer<br />

buffer with a mutual exclusion object (MUTEX). After all of this is done, the systems<br />

switches back to the execution thread, and when it next reads data from terminals,<br />

it Þnds any new copies in the transfer buffer and uses these as the new values. As<br />

you can imagine, copying image data between these layers can be quite time and<br />

RAM consuming, especially if the dataset is large or inappropriately formatted.<br />

You need to decide if you are willing to trade off system execution speed for<br />

image display — if you do not really need to display an image on your front panel,<br />

I suggest that you do not (perhaps create a modal sub-VI that the user can view only<br />

when it is required). On the other hand, you may not be able to get away from telling<br />

the user what is going on, but you will need to think carefully about the required<br />

update rate and how you are going to transfer the data.<br />

4.1 SIMPLE DISPLAY TECHNIQUES<br />

If you are reading this book, then you probably have already installed the NI Vision<br />

toolkit, and perhaps even played around with some of the example VIs that come<br />

with it. Figure 4.1 is a simple example that you might recognize (it has been slightly<br />

modiÞed from its original functionality). As you can see from the comment text in<br />

65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!