11/07/2011

PLC-Image Analysis

This chapter is divided into two parts. In the first part, we discuss the most relevant image analysis and machine vision techniques, starting with the analysis of pixel values and particle measurements. Another main topic is an introduction to pattern matching.

The exercises in this chapter, like the ones before, mainly describe how to use specific functions directly in LabVIEW and IMAQ Vision. Although it would be possible to use the IMAQ Vision Builder (I do use it in some cases), I focus on IMAQ Vision programs because of their greater flexibility.

The second part of this chapter deals with some application examples, which use some of the described techniques.

Pixel Value Analysis

Although this chapter would be the correct place for the histogram function, we already discussed it in Chapter 4 on page 151, so go there for detailed information. Another function, which gives a pixel value distribution, is discussed here: the line profile.

Line Profile

The line profile function simply visualizes the pixel values (gray-level values for gray-scaled images) along a line, which must be specified by its coordinates or results from a manually drawn line. Figure 5.1 shows this function in the IMAQ Vision Builder.

Figure 5.1. Line Profile Function in IMAQ Vision Builder

graphics/05fig01.jpg

Directly in LabVIEW and IMAQ Vision, you must specify the line coordinates by using an array control or an array constant. Exercise 5.1 shows how.

Exercise 5.1: Line Profile in Images.

Create a LabVIEW VI that draws the pixel value profile along a previously defined line in an image, using the function IMAQ Line Profile (found in Motion and Vision / Image Processing / Analysis). Figures 5.2 and 5.3 show a possible solution.

Actually, it is more convenient to draw the line directly in the image, using a function like IMAQ SelectLine, much like the behavior of IMAQ Vision Builder. I leave the extension of Exercise 5.1 up to you.

Figures 5.2 and 5.3 also show another interesting group of VIs: the overlay functions. You can find them in Motion and Vision / Vision Utilities / Overlay (see Figure 5.4); they are useful if you want to provide additional information in the IMAQ image window itself.

Figure 5.2. Line Profile of an Image

graphics/05fig02.gif

Figure 5.3. Diagram of Exercise 5.1

graphics/05fig03.gif

Figure 5.4. Menu Palette Containing Overlay Functions

graphics/05fig04.gif

Almost all overlay functions have the following inputs:

· the original image;

· the item type, which should be placed over the original image, for example:

o single points,

o lines (single or multiple),

o rectangles,

o circles and ovals,

o text,

o bitmaps;

· at least one coordinate pair, specifying where to place the overlay;

· the color of the overlay (not with bitmaps).

The only output is the resulting image with the overlay information, so the overlay is typically placed between processing or analysis functions and the IMAQ WindDraw function.

I used two different overlay functions in Exercise 5.1. As you can see in Figure 5.3, the first one simply draws the line you can specify in the Line Coordinates control. Note that the line coordinates are stored in a 4 x 1 array; but the data required by IMAQ OverlayLine is two clusters of the coordinates of the start and the end point, respectively.

The second function is more complex; the exercise uses the gray-scale values of the line profile, recalculates them so that they can be displayed in the IMAQ window, and displays them on top of the red line. Red is the default color of the overlay structure; the profile color can be changed by use of a color constant, for example, to yellow.

Quantify Areas

The quantify function can be used to obtain simple statistical data about the gray-level values of pixels in a specified region. We try this exercise in IMAQ Vision Builder, when you select the menu item Quantify in the Grayscale menu. After selecting a region of interest, you can view the results (Figure 5.5).

Figure 5.5. Quantifying Image Areas with IMAQ Vision Builder

graphics/05fig05.gif

The values provided by IMAQ Vision Builder using the quantify function are:

· mean value;

· standard variation;

· minimum value, and

· maximum value.

You will get an interesting result if you let IMAQ Vision Builder construct a LabVIEW VI (Figure 5.6). Obviously, the Vision Builder does not use the function IMAQ Quantify, as we expected; it uses a function IVB Quantify instead. IMAQ Vision Builder uses the IVB functions for the automated construction of VIs because they provide a more standardized system for input and output variables.

Figure 5.6. LabVIEW Quantify VI Generated with IMAQ Vision Builder

graphics/05fig06.gif

Figure 5.7. IVB (IMAQ Vision Builder) Functions

graphics/05fig07.gif

Figure 5.7 shows the difference between the two functions used in this exercise. You can find more IVB functions following the directory path (depending on your system) ...National Instruments\IMAQ Vision Builder 6\program\ext\addons.

http://www.cadfamily.com/html/Article/PLC-Image%20Analysis_920_1.htm

http://www.cadfamily.com/html/Article/PLC-Image%20Analysis_920_2.htm

http://www.cadfamily.com/html/Article/PLC-Image%20Analysis_920_3.htm

No comments: