National Instruments IMAQ Vision for Measurement Studio manual

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

Go to page of

A good user manual

The rules should oblige the seller to give the purchaser an operating instrucion of National Instruments IMAQ Vision for Measurement Studio, along with an item. The lack of an instruction or false information given to customer shall constitute grounds to apply for a complaint because of nonconformity of goods with the contract. In accordance with the law, a customer can receive an instruction in non-paper form; lately graphic and electronic forms of the manuals, as well as instructional videos have been majorly used. A necessary precondition for this is the unmistakable, legible character of an instruction.

What is an instruction?

The term originates from the Latin word „instructio”, which means organizing. Therefore, in an instruction of National Instruments IMAQ Vision for Measurement Studio one could find a process description. An instruction's purpose is to teach, to ease the start-up and an item's use or performance of certain activities. An instruction is a compilation of information about an item/a service, it is a clue.

Unfortunately, only a few customers devote their time to read an instruction of National Instruments IMAQ Vision for Measurement Studio. A good user manual introduces us to a number of additional functionalities of the purchased item, and also helps us to avoid the formation of most of the defects.

What should a perfect user manual contain?

First and foremost, an user manual of National Instruments IMAQ Vision for Measurement Studio should contain:
- informations concerning technical data of National Instruments IMAQ Vision for Measurement Studio
- name of the manufacturer and a year of construction of the National Instruments IMAQ Vision for Measurement Studio item
- rules of operation, control and maintenance of the National Instruments IMAQ Vision for Measurement Studio item
- safety signs and mark certificates which confirm compatibility with appropriate standards

Why don't we read the manuals?

Usually it results from the lack of time and certainty about functionalities of purchased items. Unfortunately, networking and start-up of National Instruments IMAQ Vision for Measurement Studio alone are not enough. An instruction contains a number of clues concerning respective functionalities, safety rules, maintenance methods (what means should be used), eventual defects of National Instruments IMAQ Vision for Measurement Studio, and methods of problem resolution. Eventually, when one still can't find the answer to his problems, he will be directed to the National Instruments service. Lately animated manuals and instructional videos are quite popular among customers. These kinds of user manuals are effective; they assure that a customer will familiarize himself with the whole material, and won't skip complicated, technical information of National Instruments IMAQ Vision for Measurement Studio.

Why one should read the manuals?

It is mostly in the manuals where we will find the details concerning construction and possibility of the National Instruments IMAQ Vision for Measurement Studio item, and its use of respective accessory, as well as information concerning all the functions and facilities.

After a successful purchase of an item one should find a moment and get to know with every part of an instruction. Currently the manuals are carefully prearranged and translated, so they could be fully understood by its users. The manuals will serve as an informational aid.

Table of contents for the manual

  • Page 1

    IMAQ ™ IMAQ Vision for Measurement Studio ™ User Manual LabWindows/CVI IMAQ Vision for Lab Windows/CVI User Manual May 2001 Edition Part Number 323022 A-01[...]

  • Page 2

    Support Worldwide Technical Support and Product Information ni.com National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 794 0100 Worldwide Offices Australia 03 9879 5166, Austria 0662 45 79 90 0, Belgium 02 757 00 20, Brazil 011 284 5011, Canada (Calgary) 403 274 9391, Canada (Ontario) 905 7[...]

  • Page 3

    Important Information Warranty The media on which you receive National Instruments s oftware are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evi denced by receipts or other documentation. Nati onal Instruments will, at its option, rep air o[...]

  • Page 4

    Conventions The follo wing con ventions are used in this manual: » The » symbol leads you through nested menu items and dialog box options to a final action. The sequence File»Page Setup» Options directs you to pull down the File menu, selec t the Pa ge Setup item, and select Options from the last dialog box. This icon denotes a note, which ale[...]

  • Page 5

    © National Instruments Cor poration v IMAQ Vision for LabWindows/CVI User Manu al Contents Chapter 1 Introduction to IMAQ Vision About IMAQ Vision ....... .......................... ...................... .......................... ..................... 1-1 Documentation and Examples ...... .......................... ......................... ....[...]

  • Page 6

    Contents IMAQ Vision for LabWindows/CVI User Manual vi ni.com Measure Color Statistics ...................... .......................... ......................... ....................... 3-7 Comparing Colors ............ .............. ......................... ....................... ................. 3-8 Learning Color Information ........... ...[...]

  • Page 7

    Contents © National Instruments Cor poration vii IMAQ Vision for LabWindows/CVI User Manu al Training the Color Pattern Matching Algorithm ............. .................. 5-20 Defining a Search Area .............. ......................... .......................... .... 5-21 Setting Matching Parameters and Tolerances ......................... ..[...]

  • Page 8

    © National Instruments Corporation 1-1 IMAQ Vision for LabWindows/CVI User Manual 1 Introduction to IMAQ Vision This chapter describes the IMAQ Vision for LabWindows/CVI software and associated software products, discusses the documentation and examples available, outlines the IMAQ Vision function organization, and lists the steps for m aking a ma[...]

  • Page 9

    Chapter 1 Introduction to IMAQ Vision IMAQ Vision for LabWindows/CVI User Manual 1-2 ni.com Documentation » IMA Q V ision for LabW indows/CVI Function Refere nce . • Example programs — If you want examples of ho w to create specific applications, go to cvisamplesvision . • Application Notes — If you want to kno w more about advanced IMA [...]

  • Page 10

    Chapter 1 Introduction to IMAQ Vision © National Instruments Corporation 1-3 IMAQ Vision for LabWindows/CVI User Manual Table 1-1. IMAQ Vision Function T ypes Function T ype Description Image Management Functions that create space in memory for images and perform basic image manipulation. Memory Management A function that returns memo ry you no lo[...]

  • Page 11

    Chapter 1 Introduction to IMAQ Vision IMAQ Vision for LabWindows/CVI User Manual 1-4 ni.com IMAQ Machine Vision Function T ree The IMAQ Machine Vision function tree ( NIMachineVision.fp ) contains separate classes c orresponding to grou ps or types of function s. Table 1-2 lists the IMAQ Machine Vis ion function types and gives a description of eac[...]

  • Page 12

    Chapter 1 Introduction to IMAQ Vision © National Instruments Corporation 1-5 IMAQ Vision for LabWindows/CVI User Manual Creating IMAQ Vision Applications Figures 1-1 and 1-2 illustrate the steps for creating an applicatio n with IMAQ Vision. Figure 1-1 describ es the general steps to designing a Visi on application. The last step in Figure 1-1 is [...]

  • Page 13

    Chapter 1 Introduction to IMAQ Vision IMAQ Vision for LabWindows/CVI User Manual 1-6 ni.com Figure 1-2. Inspection Steps for Building a Vision Application Define Regions of Interest Chapter 3: Grayscale and Color Measurements Measure Grayscale Statistics Measure Color Statistics 1 Correct Image Distortion Create a Binary Image Improve a Binary Imag[...]

  • Page 14

    © National Instruments Corporation 2-1 IMAQ Vision for LabWindows/CVI User Manual 2 Getting Measurement-Ready Images This chapter describes how to set up your imaging system, acquire and display an image, analyze the image, and prepare the im age for additional processing. Set Up Y our Imaging System Before you acquire, analyze, and process images[...]

  • Page 15

    Chapter 2 Getting Measurement-Ready Images IMAQ Vision for LabWindows/CVI User Manual 2-2 ni.com 3. Select an image acquisition de vice that meets your needs. National Instruments offers se veral image acquisition (IMA Q) devices, such as analog color and monochrome IMA Q de vices as well as digital de vices. V isit ni.com/imaq for more information[...]

  • Page 16

    Chapter 2 Getting Measurement-Ready Images © National Instruments Corporation 2-3 IMAQ Vision for LabWindows/CVI User Manual If you plan to use filtering or blob analysis f unctions on the image, s et the appropriate border size for th e image. The default border size is 3. When you create an image, IMA Q V ision creates an internal image structur[...]

  • Page 17

    Chapter 2 Getting Measurement-Ready Images IMAQ Vision for LabWindows/CVI User Manual 2-4 ni.com Source and Destination Images Some IMAQ Vision fun ctions that modify the cont ents of an image have source image and destination image input parameters. The source image receives the image to process. The destination image receiv es the processing resu[...]

  • Page 18

    Chapter 2 Getting Measurement-Ready Images © National Instruments Corporation 2-5 IMAQ Vision for LabWindows/CVI User Manual • imaqAdd(myImageA, myImageA, myImageB); This function adds two source images and stores the result in the first source image. • imaqAdd(myImageB, myImageA, myImageB); This function adds two source images and st ores the[...]

  • Page 19

    Chapter 2 Getting Measurement-Ready Images IMAQ Vision for LabWindows/CVI User Manual 2-6 ni.com Acquiring an Image Use one of the foll owing methods to acquire im ages with a National Instruments im age acquisition (IMAQ) d evice: • Acquire a single image using imaqEasyAcquire() . When you call this function, it in itializes the IMA Q device and[...]

  • Page 20

    Chapter 2 Getting Measurement-Ready Images © National Instruments Corporation 2-7 IMAQ Vision for LabWindows/CVI User Manual Use imaqReadVisionFile() to open an image file containing additional information, such as calibration i nformation, template inf ormation for pattern matching, or overlay information. For more information about pattern match[...]

  • Page 21

    Chapter 2 Getting Measurement-Ready Images IMAQ Vision for LabWindows/CVI User Manual 2-8 ni.com Attach Calibration Information If you want to attach the calibr ation information of th e current setup to each image you acquire, use imaqCopyCalibrationInfo() .T h i s function takes in a source im age containing the calibrat ion information and a des[...]

  • Page 22

    Chapter 2 Getting Measurement-Ready Images © National Instruments Corporation 2-9 IMAQ Vision for LabWindows/CVI User Manual this range in processing functions, such as determining a threshold ran ge during blob an alysis. If the image quality does not meet you r needs, try to improv e the imaging conditions to get the desi red image quality . Y o[...]

  • Page 23

    Chapter 2 Getting Measurement-Ready Images IMAQ Vision for LabWindows/CVI User Manual 2-10 ni.com transformations. For more information about these lookup tables, see Chapter 5, Image Processing ,i nt h e IMAQ Visi on Concepts Manual . • imaqLookup() — Con verts the pixel v alues of an image by replacing them with values from a user -defined lo[...]

  • Page 24

    Chapter 2 Getting Measurement-Ready Images © National Instruments Corporation 2-11 IMAQ Vision for LabWindows/CVI User Manual Nth Order Filter The imaqNthOrderFilter() function allows you to define a lowpass or highpass filter depending on the val ue of N that you choose. One specific Nth order filter, the median filter, removes speckle noise, whi[...]

  • Page 25

    Chapter 2 Getting Measurement-Ready Images IMAQ Vision for LabWindows/CVI User Manual 2-12 ni.com An image can hav e extraneous noise, such as periodic stripes, introduced during the digitization process. In the frequency domain, the periodic pattern is reduced to a limited set of high spatial fr equencies. Also, the imaging setup may produce non-u[...]

  • Page 26

    Chapter 2 Getting Measurement-Ready Images © National Instruments Corporation 2-13 IMAQ Vision for LabWindows/CVI User Manual 3. T o transform yo ur image back to the spatial domain, use imaqInverseFFT() . Complex Image Operations The imaqExtractComplexPlane() and imaqReplaceComplexPlane() functions allow you to access, process, and update indepen[...]

  • Page 27

    © National Instruments Corporation 3-1 IMAQ Vision for LabWindows/CVI User Manual 3 Grayscale and Color Measurements This chapter describes how to take measurements from grayscale a nd color images. You can make inspection decisions based on image statistics, such as the mean intensity level in a region. Based on the image statisti cs, you can per[...]

  • Page 28

    Chapter 3 Grayscale and Color Mea surements IMAQ Vision for LabWindows/CVI User Manual 3-2 ni.com Table 3-1. T ools Palette Functions Icon To o l N a m e Function Selection T ool Select an R OI in the image an d adjust the position of its co ntrol points and contours. Action: Click on the desired R OI or control points. Point Select a pix el in the[...]

  • Page 29

    Chapter 3 Grayscale and Color Measurements © National Instruments Corporation 3-3 IMAQ Vision for LabWindows/CVI User Manual Hold down <Shift> while dra w ing an R OI if you want to constrain the R OI to the horizontal, vertical, or diagonal axes when pos s ible. Use the selection tool to position an ROI b y its control p oints or vertices. [...]

  • Page 30

    Chapter 3 Grayscale and Color Mea surements IMAQ Vision for LabWindows/CVI User Manual 3-4 ni.com Figure 3-2. ROI Constructor 2. Select an R OI tool from the tools palette. 3. Draw an R OI on your image. Resize and reposition the R OI unti l it designates the area you want to inspect. 4. Click the OK button to output a descriptor of t he region you[...]

  • Page 31

    Chapter 3 Grayscale and Color Measurements © National Instruments Corporation 3-5 IMAQ Vision for LabWindows/CVI User Manual Figure 3-3. T ools Palette T ools and Information The following list describes ho w you can display the tools palette in a separate window and manipulate the palette. • Use imaqShowToolWindow() to display the tools window [...]

  • Page 32

    Chapter 3 Grayscale and Color Mea surements IMAQ Vision for LabWindows/CVI User Manual 3-6 ni.com Y ou can also use imaqSelectPoint() , imaqSelectLine() , imaqSelectRect() ,a n d imaqSele ctAnnulus() to define regions of interest. Follo w these steps to use these functions: 1. Call the function to display an image in an ROI Constructor windo w . On[...]

  • Page 33

    Chapter 3 Grayscale and Color Measurements © National Instruments Corporation 3-7 IMAQ Vision for LabWindows/CVI User Manual When you need to make intensity measurements on particles in an image, you can use a mask to define the particles. First, threshold your image to make a new binary image. Fo r more information on binary images, see Chapter 4[...]

  • Page 34

    Chapter 3 Grayscale and Color Mea surements IMAQ Vision for LabWindows/CVI User Manual 3-8 ni.com image. Using imaqReplaceColorPlanes() , you can reassemble a color image from a set of three 8-bit images, where each image becomes one of the three primary components. Figure 3-4 illu strates how a color image breaks down into its three components. Fi[...]

  • Page 35

    Chapter 3 Grayscale and Color Measurements © National Instruments Corporation 3-9 IMAQ Vision for LabWindows/CVI User Manual 2. Use the entire image or regions in the image to learn the color information using imaqLearnColor() , which outputs a color spectrum that contains a compact description of the color information that you learned. Use the co[...]

  • Page 36

    Chapter 3 Grayscale and Color Mea surements IMAQ Vision for LabWindows/CVI User Manual 3-10 ni.com Figur e 3-5. T emplate Color Information Specifying the Color Information to Learn You can learn the color information associated with an entire image, a region in an image, or multiple regions in an image. Using the Entire Image You can use an entire[...]

  • Page 37

    Chapter 3 Grayscale and Color Measurements © National Instruments Corporation 3-11 IMAQ Vision for LabWindows/CVI User Manual Figure 3-7. Using a Single Region to Learn Color Distribution Using Multiple Regions in the Image The interaction of light with an object ’ s surface creates the observed color of that object. The colo r of a surface depe[...]

  • Page 38

    Chapter 3 Grayscale and Color Mea surements IMAQ Vision for LabWindows/CVI User Manual 3-12 ni.com Figure 3-8. Using Multiple Regions to Learn Color Distribution Choosing a Color Representation Sensitivity When you learn a color, you need to specify the sensitivity required to specify the color information. An image containing a few, well-separated[...]

  • Page 39

    Chapter 3 Grayscale and Color Measurements © National Instruments Corporation 3-13 IMAQ Vision for LabWindows/CVI User Manual Ignoring Learned Colors Ignore certain color components in color m atching by replacing the corresponding componen t in the input color spectrum array to – 1. For example, by replacing the last component in the c olor spe[...]

  • Page 40

    © National Instruments Corporation 4-1 IMAQ Vision for LabWindows/CVI User Manual 4 Blob Analysis This chapter describes how to perform blob (Binary Large Object) analysis on your images. Use blob analy sis to find statistical informatio n about blobs, such as the presence, size, number, and location of blob regions. With this information , you ca[...]

  • Page 41

    Chapter 4 Blob Analysis IMAQ Vision for LabWindows/CVI User Manual 4-2 ni.com Correct Image Distortion If you need to make accurate shape measurements based on the blobs i n an image containing perspective and nonlinear distortion errors, correct the distortion usi ng the calibration inform ation you attached to your image. Use imaqCorrectCalibrate[...]

  • Page 42

    Chapter 4 Blob Analysis © National Instruments Corporation 4-3 IMAQ Vision for LabWindows/CVI User Manual Improve the Binar y Image After you threshold your image, you m ay want to improve the resulting binary image with bin ary morphology. You can use primary binary morphology or advanced bi nary morphology to remove unwanted bl obs, separate con[...]

  • Page 43

    Chapter 4 Blob Analysis IMAQ Vision for LabWindows/CVI User Manual 4-4 ni.com If you know enough about the shape features of the blobs you want to keep, use imaqParticleFilter() to f ilter out parti cles that do not interest you. If you do not hav e enough informat ion about the particles you want to keep at this point in your processing, use the p[...]

  • Page 44

    Chapter 4 Blob Analysis © National Instruments Corporation 4-5 IMAQ Vision for LabWindows/CVI User Manual commonly used measurements, including the area, projection along the x-axis and y-axis, and perimeter of each blob . • imaqSelectParticles() — This function selects information about blobs from th e reports generated by imaqGetParticleInfo[...]

  • Page 45

    Chapter 4 Blob Analysis IMAQ Vision for LabWindows/CVI User Manual 4-6 ni.com IMAQ_MAX_SEGMENT_LEFT_COLUMN leftmost x-coordinate of longest horizontal lin e segment in a particle IMAQ_MAX_SEGMENT_TOP_ROW y-coordinate of longest horizontal line segment IMAQ_PERIMETER length of the outer con tour of the particle in user-defined units IMAQ_PERIMETER_O[...]

  • Page 46

    Chapter 4 Blob Analysis © National Instruments Corporation 4-7 IMAQ Vision for LabWindows/CVI User Manual Convert Pixel Coordinates to Real-W orld Coordinates If you need to find the location of the center of mass o r the bounding rectangle of the blobs in real-world units, use imaqTransformPixelToRealWorld() . IMAQ_ELLIPSE_MAJOR total length of t[...]

  • Page 47

    © National Instruments Corporation 5-1 IMAQ Vision for LabWindows/CVI User Manual 5 Machine Vision This chapter describes how to perform many common machine vision inspection tasks. The most common inspection tasks are detecting the presence or absence of parts in an image and measuring the dimensions of parts to see if they meet specifications. M[...]

  • Page 48

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-2 ni.com Figure 5-1 illustrates the basic steps involved in perfor ming machine vision. Diagram items enclosed with dashed li nes are optional steps. Figure 5-1. Steps to Performing Machine Vision Locate Objects to Inspect In a typical machine vision application, you extract meas[...]

  • Page 49

    Chapter 5 Machine Vision © National Instruments Corporation 5-3 IMAQ Vision for LabWindows/CVI User Manual appears shifted and rotated in the image you need to process. This coordinate system is referred to as the measurement coordinate system. The m easurement methods automatically mov e the R OIs to the correct position using the positi on of th[...]

  • Page 50

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-4 ni.com Figure 5-2. Coordinate Systems of a Reference Image and Inspection Image b. I f y o u u s e imaqFindTransformRects() , specify two rectangles, each containing one separate, s traight boundary of the object, as shown in Figure 5-3. The boun daries cannot be parallel. The [...]

  • Page 51

    Chapter 5 Machine Vision © National Instruments Corporation 5-5 IMAQ Vision for LabWindows/CVI User Manual Figure 5-3. Locating Coordinat e S ystem Axes with T wo Search Area s 2. Use the options parameter to choose the options you need to locate the edges on the object, the coordinate system axi s direction, and the results that you want to ov er[...]

  • Page 52

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-6 ni.com 1. Defi ne a template that represents the part of the object that you want to use as a reference feature. For more information about def ining a template, see the Find Measurement Points section. 2. Defi ne a rectangular search area in which you expect to find the templa[...]

  • Page 53

    Chapter 5 Machine Vision © National Instruments Corporation 5-7 IMAQ Vision for LabWindows/CVI User Manual C h o o s i n gaM e t h o dt oB u i l dt h eC o o r d i n a t eT r a n s f o r m The following flowchart guides you thro ugh choosing the best method for building a coordinate t ransform for your application . Figure 5-4. Building a Coordinat[...]

  • Page 54

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-8 ni.com Set Search Areas Select regions of interest ( ROIs) in your images to lim it the areas in which you perform your processin g and inspection. You can defin e ROIs interactively or programmatically. Interactively Defining Regions Follow these steps to interactively define [...]

  • Page 55

    Chapter 5 Machine Vision © National Instruments Corporation 5-9 IMAQ Vision for LabWindows/CVI User Manual Programmatically Defining Regions When you have an automated application, you need to define regions of interest programmatically. You can programmatically define regions in two ways: • Specify the contours of the R OI. • Specify individu[...]

  • Page 56

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-10 ni.com Figure 5-5. Finding a Straight Feature 1 Search Region 2S e a r c h L i n e s 3 Detecte d Edge Points 4 Line Fit to Edge Points 2 1 4 3[...]

  • Page 57

    Chapter 5 Machine Vision © National Instruments Corporation 5-11 IMAQ Vision for LabWindows/CVI User Manual If you w ant to find poi nts along a circular e dge and find t he circle that best fits the edge, as sho wn in Figure 5-6, u se imaqFindCircularEdge() . Figure 5-6. Finding a Circular Feature These functions locate the intersection points be[...]

  • Page 58

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-12 ni.com These functions require you to inpu t the coordinates of the points alo ng the search contour . Use imaqROIProfile() to obtain the coordinates along the edge of each contour in an R OI. If you have a straight line, use imaqGetPointsOnLine() to obtain the points along th[...]

  • Page 59

    Chapter 5 Machine Vision © National Instruments Corporation 5-13 IMAQ Vision for LabWindows/CVI User Manual Finding Points Using Pattern Matching The pattern matching algorith ms in IMA Q V ision measure the similarity between an idealized representation of a feature, called a template, and the feature that may be present in an image. A fea t ure [...]

  • Page 60

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-14 ni.com Figure 5-7. Symmetry Feature detail A template with relatively coarse features is less sensitive to variations in size and rotation than a model with fine features. However, the model must contain enough detail to identify it . Figure 5-8. Feature De tail Positional inf[...]

  • Page 61

    Chapter 5 Machine Vision © National Instruments Corporation 5-15 IMAQ Vision for LabWindows/CVI User Manual Background information Unique background information in a template improves search performance and accuracy. Figure 5-10. Background Information T raining the Pattern Matching Algorithm After you create a good template image, the pattern mat[...]

  • Page 62

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-16 ni.com incorrect results. To avoid this, reduce the search area so that only the desired pattern lies within the search area. The time required to locate a pattern in an im age depends on both the template size and the search area. By reducing the search area or increasing the[...]

  • Page 63

    Chapter 5 Machine Vision © National Instruments Corporation 5-17 IMAQ Vision for LabWindows/CVI User Manual However, there may be applications in whi ch the assumptions used in the algorithm are not optimal. Knowing your particular application and the images you want to process is useful in selecting the pattern matching parameters. The following [...]

  • Page 64

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-18 ni.com T esting the Search Algorithm on T est Images To determine if your selected templat e or reference pattern is appropriate for your machine vision ap plication, test the temp late on a few test images by using imaqMatchPattern() . These test images should reflect the ima[...]

  • Page 65

    Chapter 5 Machine Vision © National Instruments Corporation 5-19 IMAQ Vision for LabWindows/CVI User Manual Color pattern matching retu rns the location of the center of the template and the template orientation. Follow these general steps to f ind features in an image using co lor pattern match ing: 1. Defi ne a reference or fiducial pattern in t[...]

  • Page 66

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-20 ni.com Feature Detail A template with relatively coarse features is less sensitive to variations in size and rotation than a model with fine features. However, the model must contain enough detail to identify it . Positional Information A template with strong edges in both the[...]

  • Page 67

    Chapter 5 Machine Vision © National Instruments Corporation 5-21 IMAQ Vision for LabWindows/CVI User Manual The training or learning process is time-intensi ve because the algorithm attempts to find optimal features of the template f or the particular matching process. Ho wev er, you can train the pattern matching algorithm of fline, and sav e the[...]

  • Page 68

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-22 ni.com Figure 5-12. Selecting a Search Area for Color Pattern Matc hing The time required to locate a pattern in an im age depends on both the template size and the search area. By reducing the search area or increasing the template size, you can reduce the required search tim[...]

  • Page 69

    Chapter 5 Machine Vision © National Instruments Corporation 5-23 IMAQ Vision for LabWindows/CVI User Manual The following are some elements in the IMA Q V ision p attern matching algorithm and how they influence pattern matching: color sensitivity , search strateg y , color score weight, ignore background colors, minimum contrast, and rotation ang[...]

  • Page 70

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-24 ni.com Note Use the IMAQ_CONSERVATIVE strategy if you hav e multiple targets located v er y close to each other in the image. Decide on the best strategy b y experimentin g with the different options. Color Score W eight When you search for a template using both color and shap[...]

  • Page 71

    Chapter 5 Machine Vision © National Instruments Corporation 5-25 IMAQ Vision for LabWindows/CVI User Manual reference pattern in all cases, you have selected a good template. Otherwise, refine the current template, or select a better template until both training and testing are successful. Finding Points Using Color Location Color location algorit[...]

  • Page 72

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-26 ni.com Convert Pixel Coordinates to Real-W orld Coordinates The measurement points you located with edge detection and pattern matching are in pixel coordinates. If you need to make measurements using real-worl d units, use imaqTransformPixelToRealWorld() to convert the pixel [...]

  • Page 73

    Chapter 5 Machine Vision © National Instruments Corporation 5-27 IMAQ Vision for LabWindows/CVI User Manual Analytic Geometr y Measurements Use the following functions to make geometri cal measurements from the points you detect in the image: • imaqFitLine() — Fits a line to a set of points and computes the equation of the line. • imaqFitCir[...]

  • Page 74

    Chapter 5 Machine Vision IMAQ Vision for LabWindows/CVI User Manual 5-28 ni.com Use imaqFindLCDSegments() to calculate the regions of interest around each digit in an LCD or LED. T o find the area of each digit, all the segments of the indicator must be activ ated. Use imaqReadLCD() to read multiple digits of an LCD or LED. Use imaqReadBarcode() to[...]

  • Page 75

    Chapter 5 Machine Vision © National Instruments Corporation 5-29 IMAQ Vision for LabWindows/CVI User Manual Y ou can configure the following processing functions to ov erlay different types of information on the i nspection image: • imaqFindEdge() • imaqFindCircularEdge() • imaqFindConcentricEdge() • imaqClampMax() • imaqClampMin() • i[...]

  • Page 76

    © National Instruments Corporation 6-1 IMAQ Vision for LabWindows/CVI User Manual 6 Calibration This chapter describes how to calibrate yo ur imaging system, save calibration information , and attach calibration informati on to an image. After you set up your imaging system, you may want to calibrat e your system. If your imaging setup is suc h th[...]

  • Page 77

    Chapter 6 Calibration IMAQ Vision for LabWindows/CVI User Manual 6-2 ni.com Defining a Calibration T emplate You can define a calibration templat e by supplying an image of a grid or providing a list of pixel coordinat es and their corresponding real-world coordinates. This section discusses the grid meth od in detail. A calibration template is a u[...]

  • Page 78

    Chapter 6 Calibration © National Instruments Corporation 6-3 IMAQ Vision for LabWindows/CVI User Manual The origin, expressed in pixels, def ines the center of y our coordinate system. The angle specifies the orientation of your coordinate system with respect to the angle of the topmost row of dots in the grid image. The calibration pro cedure aut[...]

  • Page 79

    Chapter 6 Calibration IMAQ Vision for LabWindows/CVI User Manual 6-4 ni.com Figure 6-3. A Calibration Grid and an Image of the Grid Note If you specify a list of points instead of a grid for the calibration process, the software def ines a default coordinate system, as follows: 1. The origin is placed at the point in the list with the lowest x-coor[...]

  • Page 80

    Chapter 6 Calibration © National Instruments Corporation 6-5 IMAQ Vision for LabWindows/CVI User Manual Figure 6-4. Defining a Coordinate System Learning Calibration Information After you def ine a calibration grid and reference axis, acquire an image of the grid using the current imaging setup . For information about acquiring images, see the A c[...]

  • Page 81

    Chapter 6 Calibration IMAQ Vision for LabWindows/CVI User Manual 6-6 ni.com Specifying Scaling Factors Scaling factors are the real-world distances between the dots in the calibration grid in the x and y d irections and the units i n which the distances are measured. Use the GridDescriptor structure to specify the scaling factors. Choosing a Region[...]

  • Page 82

    Chapter 6 Calibration © National Instruments Corporation 6-7 IMAQ Vision for LabWindows/CVI User Manual IMAQ_PERSPECTIVE to choose the perspecti ve calibration algorithm. Learning and applying perspect i ve projection is less com putationally intensi ve than the nonlinear method. Howe ver , perspecti ve projection cannot handle nonlinear di storti[...]

  • Page 83

    Chapter 6 Calibration IMAQ Vision for LabWindows/CVI User Manual 6-8 ni.com Also, adjust the range pa rameter to distinguish t he dots from the background. 3. Select another learning algorithm. When no nlinear lens distortion is present, using perspecti ve projection sometimes results in a lo w learning score. Note A high score does not reflect the[...]

  • Page 84

    Chapter 6 Calibration © National Instruments Corporation 6-9 IMAQ Vision for LabWindows/CVI User Manual Simple Calibration When the axis of your camera is perpendicular to the image plane and lens distortion is negligibl e, use simple calibration. In simple calibratio n, a pixel coordinate is transformed to a real-world coordinate through scalin g[...]

  • Page 85

    Chapter 6 Calibration IMAQ Vision for LabWindows/CVI User Manual 6-10 ni.com Save Calibration Information After you learn the calibration inf ormation, you can save it so that you do not have to relearn the information f or subsequent processing. Use imaqWriteVisionFile() to save the image of the grid and its associated calibration inform ation to [...]

  • Page 86

    © National Instruments Cor poration A-1 IMAQ Vi sion for LabWindows/CVI User Manual A T echnical Support Resources W eb Support National Instruments W eb support is your first stop for help in solving installation, configuration, and application pro blems and questions. Onlin e problem-solving and di agnostic resources include frequ ently asked qu[...]

  • Page 87

    Appendix A T echnical Support R esources IMAQ Vision for LabWindows/CVI User Manual A-2 ni.com W orldwide Support National Instruments has of fices located around the world to help address your support needs. Y ou can access our branch off ice W eb sites from the W o rldwide Of fices section of ni.com . Branch of fice W eb sites provide up-to-date [...]

  • Page 88

    © National Instruments Cor poration G-1 IMAQ Vision for LabWindows/CVI User Manu al Glossar y Numbers/Symbols 1D One-dimensional. 2D T wo-dimensi onal. 3D Three-dimensional. A AIPD National Instruments pro prietary image file format used for saving complex images and calibration inform ation pertaining to step and spatial units (extension APD). al[...]

  • Page 89

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-2 ni.com B b Bit. One binary d igit, either 0 or 1. B Byte. Eight related bits of data, an eight-b it binary number . Also denotes the amount of memory required t o store one byte of data. barycenter The grayscale value representing the centroid of the range of an image's grayscale v alues [...]

  • Page 90

    Glossary © National Instruments Cor poration G-3 IMAQ Vision for LabWindows/CVI User Manu al brightness (1) A constant added to the red, green, and b lue components of a color pixel during the color decoding process. (2) The perception by which white objects are distinguished from gray and light objects from dark objects. b u f fer T emporary stor[...]

  • Page 91

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-4 ni.com CLUT Color lookup table. T able for conv erting the value of a pixel in an image into a red, green, and blue (RGB) i ntensity . color images Images containing color inform ation, usually encoded in the RGB form. color location The technique that locates a color templ ate in a color imag[...]

  • Page 92

    Glossary © National Instruments Cor poration G-5 IMAQ Vision for LabWindows/CVI User Manu al cross correlation A technique that compares the similar ity of two images or parts of an image. Y ou can use cross correlation to find the optimal position where similarity exists. D Danielsson function Similar to the distance functions, b ut with more acc[...]

  • Page 93

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-6 ni.com E edge Defined b y a sharp chang e (transition) in the pixel intensities in an image or along an array of pix els. edge contrast The dif ference betw een the a verage pixel intensity before and the a verage pixel intensity after the edge. edge detection Any of se veral techniques to ide[...]

  • Page 94

    Glossary © National Instruments Cor poration G-7 IMAQ Vision for LabWindows/CVI User Manu al form W indo w or area on the screen on which you place controls and indicators to create the user interface for your p rogram. Fourier spectrum The magnitu de information of the Fourier transform of an image. Fourier transform T ransforms an image from the[...]

  • Page 95

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-8 ni.com H highpass attenuation Applies a linear attenuation to the frequencies in an image, wit h no attenuation at the highest frequency and full attenuation a t the lo west frequency . highpass FFT filter Remov es or attenuates low frequencies present in the FFT domain of an image. highpass f[...]

  • Page 96

    Glossary © National Instruments Cor poration G-9 IMAQ Vision for LabWindows/CVI User Manu al hue offset angle The value added to all hue values so that the discontinuity occurs outside the values of interest during analysis . I image A two-dimen sional light intensity function f (x , y) where x and y denote spatial coordinates an d the value f at [...]

  • Page 97

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-10 ni.com image visualization The present ation (display) of an image (image data) to the user . imaging Any proces s of acquiring and displaying images and analyzing image data. IMA Q Image Acquisition. inner gradient Finds the inner boundary of objects. inspection The process by which parts ar[...]

  • Page 98

    Glossary © National Instruments Cor poration G-11 IMAQ Vision fo r LabWindows/CVI User Manual J JPEG Joint Photographic Expert s Group. Image file format for storing 8-bit and color images with lossy comp ression (extension JPG). K kernel Structure that represents a pixel and its relationship to its neighb ors. The relationship is specified b y we[...]

  • Page 99

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-12 ni.com logic operators The image operations AND, NAND, OR, XOR, NOR, XNOR, difference, m a s k ,m e a n ,m a x ,a n d m i n . lossless compression Compression in which the decompressed image is identical to the original image. lossy compression Compressio n in which the decompressed image is [...]

  • Page 100

    Glossary © National Instruments Cor poration G-13 IMAQ Vision fo r LabWindows/CVI User Manual match score A number ranging from 0 to 1000 that ind icates ho w c losely an acquired image matches the template image. A match score of 1000 indicates a perfect match. A match score of 0 indicates no match. median filter A lo wpass filter that assigns to[...]

  • Page 101

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-14 ni.com Nth order filter Filters an image using a nonlinear f ilter . This filter orders (or classif ies) the pixel v alues surroun ding the pixel being processed. The pixel being processed is set to the Nth pixel v alue, wh ere N is the order of the filter . number of planes (in an imag e) Th[...]

  • Page 102

    Glossary © National Instruments Cor poration G-15 IMAQ Vision fo r LabWindows/CVI User Manual particle A connected region or grouping of pixels in an image in which all pixels hav e the sam e intensity lev el. Particles are also re ferred to as blobs or objects. pattern matching The technique used to quickly locate a grayscale templ ate within a g[...]

  • Page 103

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-16 ni.com pyramidal matching A technique used to increase the speed of a pattern matchi ng algorithm by matching subsampled versions of the image and the reference pattern. Q quantitativ e analysis Obtaining various measurements of objects in an image. R real time A property of an ev ent or syst[...]

  • Page 104

    Glossary © National Instruments Cor poration G-17 IMAQ Vision fo r LabWindows/CVI User Manual rotation-inv ariant matching A pattern matching technique i n which the reference pattern can be located at any orientation in t he test image as well as rotated at any de gree. S saturation The amount of white added to a p ure color . Saturation relates [...]

  • Page 105

    Glossary IMAQ Vision for LabWindows/CVI User Manual G-18 ni.com spatial resolution The num ber of pixels in an image, in terms of the number of rows and columns in the image. square function See exponential function . square root function See lo garithmic function . standard representation Contains the low-frequenc y information at t he corners and[...]

  • Page 106

    Glossary © National Instruments Cor poration G-19 IMAQ Vision fo r LabWindows/CVI User Manual V v al ue The grayscale intensity of a color pixel computed as the av erage of t he maximum and minimu m red, green, and blue values of that pixel. W watershed A technique used to segment an image into multiple regions. web inspection The process of detec[...]

  • Page 107

    © National Instruments Cor poration I-1 IMAQ Vision for LabWindows/CVI User Manual Index A acquiring measurement-ready images. See measurement-ready images, acquiring. analytic geometry measurements, 5-27 a n a l y z i n gi m a g e s ,2 - 8t o2 - 9 Annulus too l (table), 3-2 application development, 1-5 to 1-6 general steps (figure), 1-5 inspectio[...]

  • Page 108

    Index IMAQ Vision for LabWindows/CVI User Manual I-2 ni.com defining template images, 5-19 t o 5-20 setting matching parameters and tolerances, 5-22 to 5-24 color score weight, 5-24 color sensitivity, 5- 23 minimum contr ast, 5-24 rotation angle r anges, 5-24 search strategy, 5-23 to 5-24 testing search algorit hm on test images, 5-24 to 5-25 train[...]

  • Page 109

    Index © National Instruments Cor poration I-3 IMAQ Vision for LabWindows/CVI User Manual lowpass, 2-10 lowpass frequency, 2-12 Nth order, 2-11 finding measurement points. See measurement points, finding. Freehand Line tool (table), 3-2 Freehand tool (table), 3-3 frequency domain, 2-11 f u n c t i o nt r e e ,1 - 2t o1 - 4 IMAQ Machine Vision funct[...]

  • Page 110

    Index IMAQ Vision for LabWindows/CVI User Manual I-4 ni.com imaqAdd() function, 2-4 to 2-5 imaqAddRectContour() fu nction, 3-6 imaqArrayToComplextPlane() funct ion, 2-13 imaqArrayToImage() function, 2-7, 6-8 imaqAttenuate() function, 2-1 2 IMAQ_AUTOM method, 4-4 imaqAutoThreshold() f unction, 4-2 imaqCalcCoeff() function, 4-5 particle measurements [...]

  • Page 111

    Index © National Instruments Cor poration I-5 IMAQ Vision for LabWindows/CVI User Manual imaqLightMeterPoint() functi on, 3-6, 3-7 imaqLightMeterRect() function, 3-6, 3-7 imaqLineProfile() function, 2-9 imaqLookup() function, 2 -10 imaqLowpass() function, 2-10 imaqMaskToRoi() funct ion, 3-7 imaqMatchColor() fun ction, 3-9 imaqMatchColorPatter n() [...]

  • Page 112

    Index IMAQ Vision for LabWindows/CVI User Manual I-6 ni.com imaqWriteVisionFile() funct ion, 5-15, 5-25, 6-10 imgInterfaceOpen() function, 2-6 imgSessionOpen() function, 2-6 imgSnap() function, 2-6 instrument reader measurements, 5-27 to 5-28 invalidation of calib ration, 6-8 L learning calibration inf ormation, 6-5 to 6-8 choosing learning algorit[...]

  • Page 113

    Index © National Instruments Cor poration I-7 IMAQ Vision for LabWindows/CVI User Manual pattern matching, 5-13 to 5-1 8 measurement-ready images, acquiring, 2-1 to 2-13 acquiring or reading images, 2-5 to 2-7 a n a l y z i n gi m a g e s ,2 - 8t o2 - 9 attaching calibration information, 2-8 calibrating imaging sy stem, 2-2 c r e a t i n gi m a g [...]

  • Page 114

    Index IMAQ Vision for LabWindows/CVI User Manual I-8 ni.com S scaling factors, for calibrati on, 6-6 scaling method, for calibr ation, 6-8 search contour, finding points along e dge, 5-11 to 5-12 Selection tool (table), 3-2 source and destination images, 2-4 to 2-5 statistics. See color statistics; grayscale statistics. system integration, by Natio[...]