National Instruments IMAQ Vision for LabWindows TM /CVI User Manual
National Instruments IMAQ Vision for LabWindows TM /CVI User Manual

National Instruments IMAQ Vision for LabWindows TM /CVI User Manual

For labwindows/cvi
Table of Contents

Advertisement

Quick Links

IMAQ
TM
IMAQ Vision
for LabWindows
TM
/CVI
TM

User Manual

IMAQ Vision for LabWindows/CVI User Manual
August 2004 Edition
Part Number 371266A-01

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the IMAQ Vision for LabWindows TM /CVI and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for National Instruments IMAQ Vision for LabWindows TM /CVI

  • Page 1: User Manual

    IMAQ IMAQ Vision for LabWindows /CVI User Manual IMAQ Vision for LabWindows/CVI User Manual August 2004 Edition Part Number 371266A-01...
  • Page 2 For further support information, refer to the Technical Support and Professional Services appendix. To comment on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter the info code feedback. © 2001–2004 National Instruments Corporation. All rights reserved.
  • Page 3: Important Information

    The reader should consult National Instruments if errors are suspected. In no event shall National Instruments be liable for any damages arising out of or related to this document or the information contained in it.
  • Page 4: Table Of Contents

    Attach Calibration Information...2-8 Analyze an Image ...2-8 Improve an Image ...2-9 Lookup Tables ...2-10 Filters...2-10 Convolution Filter ...2-11 Nth Order Filter...2-11 Grayscale Morphology ...2-11 FFT ...2-12 Complex Image Operations ...2-13 © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual...
  • Page 5 Contents Chapter 3 Making Grayscale and Color Measurements Define Regions of Interest... 3-1 Defining Regions Interactively ... 3-1 Tools Palette Transformation ... 3-5 Defining Regions Programmatically... 3-6 Defining Regions with Masks... 3-6 Measure Grayscale Statistics... 3-7 Measure Color Statistics... 3-7 Comparing Colors ...
  • Page 6 Using the Learning Score...6-7 Learning the Error Map...6-8 Learning the Correction Table ...6-8 Setting the Scaling Method ...6-8 Calibration Invalidation ...6-8 Simple Calibration ...6-9 Save Calibration Information...6-10 Attach Calibration Information...6-10 © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual Contents...
  • Page 7 Contents Appendix A Technical Support and Professional Services Glossary Index IMAQ Vision for LabWindows/CVI User Manual viii ni.com...
  • Page 8: About This Manual

    This font is also used for the proper names of disk drives, paths, directories, programs, subprograms, subroutines, device names, functions, operations, variables, filenames, and extensions. © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual ™ ™...
  • Page 9: Related Documentation

    About This Manual Related Documentation In addition to this manual, the following documentation resources are available to help you create your vision application. IMAQ Vision • • NI Vision Assistant • • NI Vision Builder for Automated Inspection • • •...
  • Page 10: Other Documentation

    <CVI>\samples\vision Application Notes—If you want to know more about advanced IMAQ Vision concepts and applications, refer to the Application Notes located on the National Instruments Web site at appnotes.nsf NI Developer Zone (NIDZ)—If you want even more information about developing your vision application, visit the NI Developer Zone .
  • Page 11: Introduction To Imaq Vision

    IMAQ Vision has been tested and found to work with these ADEs, although other Note ADEs may also work. © National Instruments Corporation LabWindows/CVI version 6.0 and later Microsoft Visual C/C++ version 6.0 and later IMAQ Vision for LabWindows/CVI User Manual...
  • Page 12: Imaq Vision Function Tree

    Chapter 1 Introduction to IMAQ Vision IMAQ Vision Function Tree The IMAQ Vision function tree ( classes corresponding to groups or types of functions. Table 1-1 lists the IMAQ Vision function types and gives a description of each type. Function Type Image Functions that create space in memory for images and perform basic image Management...
  • Page 13: Imaq Machine Vision Function Tree

    Function Type Coordinate Transform Count and Measure Objects Find Patterns Locate Edges © National Instruments Corporation Description Description Functions that find coordinate transforms based on image contents. Function that counts and measures objects in an image. Function that finds patterns in an image.
  • Page 14: Creating Imaq Vision Applications

    Chapter 1 Introduction to IMAQ Vision Table 1-2. IMAQ Machine Vision Function Types (Continued) Function Type Measure Distances Measure Intensities Select Region of Interest Creating IMAQ Vision Applications Figures 1-1 and 1-2 illustrate the steps for creating an application with IMAQ Vision.
  • Page 15 Diagram items enclosed with dashed lines are optional steps. Note © National Instruments Corporation Set Up Your Imaging System Calibrate Your Imaging System Acquire or Read an Image Chapter 2: Getting Measurement-Ready Images Attach Calibration Information Make Measurements or Identify Objects...
  • Page 16 Chapter 1 Introduction to IMAQ Vision Chapter 4: Grayscale and Color Measurements Create a Binary Image Chapter 5: Particle Improve a Binary Image Analysis Make Particle Measurements Diagram items enclosed with dashed lines are optional steps. Note IMAQ Vision for LabWindows/CVI User Manual Define Regions of Interest Measure Measure...
  • Page 17: Getting Measurement-Ready Images

    Complete the following steps to set up your imaging system. © National Instruments Corporation Determine the type of equipment you need given your space constraints and the size of the object you need to inspect. Refer to Chapter 3, System Setup and Calibration, of the IMAQ Vision Concepts Manual for more information.
  • Page 18: Calibrate Your Imaging System

    Table 2-1 lists the valid image types. IMAQ Vision for LabWindows/CVI User Manual Select an IMAQ device that meets your needs. National Instruments offers several IMAQ devices, including analog color and monochrome devices as well as digital devices. Visit information about IMAQ devices.
  • Page 19 Other functions that process the contents of images require pointers to the source image(s) and to a destination image. At the end of your application, dispose of each image that you created using imaqDispose() © National Instruments Corporation Chapter 2 Description 8 bits per pixel—unsigned, standard monochrome 16 bits per pixel—signed, monochrome...
  • Page 20: Source And Destination Images

    Chapter 2 Getting Measurement-Ready Images Source and Destination Images Some IMAQ Vision functions that modify the contents of an image have source image and destination image input parameters. The source image receives the image to process. The destination image receives the processing results.
  • Page 21: Acquire Or Read An Image

    2D array to an image automatically allocate the memory space required to accommodate the image data. © National Instruments Corporation Chapter 2 imaqAdd(myImageA, myImageA, myImageB); This function adds two source images and stores the result in the first source image.
  • Page 22: Acquiring An Image

    Chapter 2 Getting Measurement-Ready Images Acquiring an Image Use one of the following methods to acquire images with a National Instruments IMAQ device. • • • • • You must use Note acquisition device. Reading a File computer into the image reference. You can read from image files stored in several standard formats: BMP, TIFF, JPEG, PNG, and AIPD.
  • Page 23: Converting An Array To An Image

    Chapter 2, Display, of the IMAQ Vision Concepts Manual. Note At the end of your application, close all open external windows using imaqCloseWindow() © National Instruments Corporation Chapter 2 to open an image file containing additional imaqReadVisionFile() Tasks.
  • Page 24: Attach Calibration Information

    Chapter 2 Getting Measurement-Ready Images Attach Calibration Information If you want to attach the calibration information of the current setup to each image you acquire, use function takes in a source image containing the calibration information and a destination image that you want to calibrate. The output image is your inspection image with the calibration information attached to it.
  • Page 25: Improve An Image

    Using the information you gathered from analyzing your image, you may want to improve the quality of your image for inspection. You can improve your image with lookup tables, filters, grayscale morphology, and FFTs. © National Instruments Corporation Chapter 2 to get the pixel distribution along a line in the...
  • Page 26: Lookup Tables

    Chapter 2 Getting Measurement-Ready Images Lookup Tables Apply areas containing significant information at the expense of other areas. A LUT transformation converts input grayscale values in the source image into other grayscale values in the transformed image. IMAQ Vision provides four functions that directly or indirectly apply lookup tables to images.
  • Page 27: Convolution Filter

    Refer to Chapter 5, Image Processing, of the IMAQ Vision Concepts Manual for more information about grayscale morphology transformations. transformations: • • • © National Instruments Corporation Chapter 2 function allows you to use a predefined set of imaqConvolve() imaqGetKernel() function allows you to define a lowpass or imaqNthOrderFilter()
  • Page 28: Fft

    Chapter 2 Getting Measurement-Ready Images • • • • Use the Fast Fourier Transform (FFT) to convert an image into its frequency domain. In an image, details and sharp edges are associated with mid to high spatial frequencies because they introduce significant gray-level variations over short distances.
  • Page 29: Complex Image Operations

    You can also convert planes of a complex image to an array and back with imaqArrayToComplexPlane() © National Instruments Corporation Chapter 2 attenuation increases. This operation preserves all of the zero frequency information. Zero frequency information corresponds to the DC component of the image or the average intensity of the image in the spatial domain.
  • Page 30: Making Grayscale And Color Measurements

    You can interactively define an ROI in a window that displays an image. Use the tools from the IMAQ Vision tools palette to interactively define and manipulate an ROI. © National Instruments Corporation Define Regions of Interest Measure Grayscale Statistics Figure 3-1.
  • Page 31 Chapter 3 Making Grayscale and Color Measurements Table 3-1 describes each of the tools and the manner in which you use them. Icon Tool Name Selection Tool Point Line Rectangle Rotated Rectangle Oval Annulus Broken Line Polygon IMAQ Vision for LabWindows/CVI User Manual Table 3-1.
  • Page 32 If you want to draw more than one ROI in a window, hold down the <Ctrl> key while drawing additional ROIs. © National Instruments Corporation Chapter 3 Function Draw a freehand line in the image.
  • Page 33 Chapter 3 Making Grayscale and Color Measurements You can display the IMAQ Vision tools palette as part of an ROI constructor window or in a separate, floating window. Follow these steps to invoke an ROI constructor and define an ROI from within the ROI constructor window: You can also use imaqSelectRect()
  • Page 34: Tools Palette Transformation

    ROI tool in an image window. The palette on the right displays the characteristics of the ROI you are drawing. © National Instruments Corporation Chapter 3 Click OK to populate a structure representing the ROI. You can use this structure as an input to a variety of functions, such as the following functions that measure grayscale intensity.
  • Page 35: Defining Regions Programmatically

    Chapter 3 Making Grayscale and Color Measurements The following list describes how you can display the tools palette in a separate window and manipulate the palette. • • • • If you want to draw an ROI without using an ROI constructor or displaying the tools palette in a separate window, use This function allows you to select a contour from the tools palette without opening the palette.
  • Page 36: Measure Grayscale Statistics

    8-bit or 16-bit images, where each image becomes one of the three primary components. Figures 3-4 and 3-5 illustrate how a color image breaks down into its three primary components. © National Instruments Corporation Chapter 3 to measure the light intensity at a imaqLightMeterPoint()
  • Page 37 Chapter 3 Making Grayscale and Color Measurements Green Blue Saturation Color Intensity Image Saturation Luminance Saturation Value Color Image saturation, intensity, luminance, or value plane of a color image into an 8-bit image. Note You can also use components of a 64-bit image. IMAQ Vision for LabWindows/CVI User Manual 8-bit Image Processing Figure 3-4.
  • Page 38: Comparing Colors

    Figure 3-6a. Figure 3-6b illustrates an unacceptable region containing background colors. © National Instruments Corporation Chapter 3 Select an image containing the color information that you want to use as a reference. The color information can consist of a single color or multiple dissimilar colors, such as red and blue.
  • Page 39 Chapter 3 Making Grayscale and Color Measurements The following sections explain when to 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 image to learn the color spectrum that represents the entire color distribution of the image.
  • Page 40 3-amp fuses better and results in high match scores (around 800) for both 3-amp fuses. Use as many samples as you want in an image to learn the representative color spectrum for a specified template. © National Instruments Corporation 3-11 IMAQ Vision for LabWindows/CVI User Manual...
  • Page 41: Choosing A Color Representation Sensitivity

    Chapter 3 Making Grayscale and Color Measurements 1 Regions Used to Learn Color Information 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 colors in the color space requires a lower sensitivity to describe the color than an image that contains colors that are close to one another in the color space.
  • Page 42: Ignoring Learned Colors

    Refer to Chapter 14, Color Inspection, of the IMAQ Vision Concepts Manual for more information about the color wheel and color bins. © National Instruments Corporation 3-13 IMAQ Vision for LabWindows/CVI User Manual...
  • Page 43: Performing Particle Analysis

    You can use different techniques to threshold your image. If all the objects of interest in your grayscale image fall within a continuous range of intensities and you can specify this threshold range manually, use imaqThreshold() © National Instruments Corporation Create a Binary Image Improve a Binary Image Make Particle Measurements in Pixels or Real-World Units Figure 4-1.
  • Page 44: Improve The Binary Image

    Chapter 4 Performing Particle Analysis If all the objects in your grayscale image are either brighter or darker than your background, you can use determine the optimal threshold range and threshold your image. Automatic thresholding techniques offer more flexibility than simple thresholds based on fixed ranges.
  • Page 45: Removing Unwanted Particles

    Improving Particle Shapes imaqMorphology() You can use the and proper-open smooth the boundaries of the particle by removing small © National Instruments Corporation to remove particles that touch the border of imaqRejectBorder() to remove large or small particles that do...
  • Page 46: Make Particle Measurements

    Chapter 4 Performing Particle Analysis isthmuses while close widens the isthmuses. Close and proper-close fill small holes in the particle. Auto-median removes isthmuses and fills holes. Refer to Chapter 9, Binary Morphology, of the IMAQ Vision Concepts Manual for more information about these methods. Make Particle Measurements After you create a binary image and improve it, you can make particle measurements.
  • Page 47 IMAQ_MT_BOUNDING_RECT_RIGHT IMAQ_MT_BOUNDING_RECT_HEIGHT IMAQ_MT_BOUNDING_RECT_WIDTH IMAQ_MT_BOUNDING_RECT_DIAGONAL IMAQ_MT_CENTER_OF_MASS_X IMAQ_MT_CENTER_OF_MASS_Y IMAQ_MT_COMPACTNESS_FACTOR IMAQ_MT_CONVEX_HULL_AREA IMAQ_MT_CONVEX_HULL_PERIMETER © National Instruments Corporation Chapter 4 Performing Particle Analysis Description X-coordinate of the leftmost particle point X-coordinate of the rightmost particle point Distance between the y-coordinate of highest particle point and the...
  • Page 48 Chapter 4 Performing Particle Analysis Table 4-1. Particle Measurements (Continued) Measurement IMAQ_MT_EQUIVALENT_ELLIPSE_MAJOR_AXIS IMAQ_MT_EQUIVALENT_ELLIPSE_MINOR_AXIS IMAQ_MT_EQUIVALENT_ELLIPSE_MINOR_AXIS_FERET IMAQ_MT_EQUIVALENT_RECT_DIAGONAL IMAQ_MT_EQUIVALENT_RECT_LONG_SIDE IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE IMAQ_MT_EQUIVALENT_RECT_SHORT_SIDE_FERET IMAQ_MT_ELONGATION_FACTOR IMAQ_MT_FIRST_PIXEL_X IMAQ_MT_FIRST_PIXEL_Y IMAQ_MT_HU_MOMENT_1 IMAQ_MT_HU_MOMENT_2 IMAQ_MT_HU_MOMENT_3 IMAQ_MT_HU_MOMENT_4 IMAQ Vision for LabWindows/CVI User Manual Description Length of the major axis of the ellipse with the same perimeter and area as the particle Length of the minor axis of the...
  • Page 49 IMAQ_MT_HOLES_PERIMETER IMAQ_MT_HYDRAULIC_RADIUS IMAQ_MT_HOLES_AREA IMAQ_MT_IMAGE_AREA IMAQ_MT_MAX_FERET_DIAMETER IMAQ_MT_MAX_FERET_DIAMETER_END_X IMAQ_MT_MAX_FERET_DIAMETER_END_Y IMAQ_MT_MAX_FERET_DIAMETER_ORIENTATION IMAQ_MT_MAX_FERET_DIAMETER_START_X © National Instruments Corporation Chapter 4 Performing Particle Analysis Description Fifth Hu moment Sixth Hu moment Seventh Hu moment Perimeter divided by the circumference of a circle with the same area...
  • Page 50 Chapter 4 Performing Particle Analysis Table 4-1. Particle Measurements (Continued) Measurement IMAQ_MT_MAX_FERET_DIAMETER_START_Y IMAQ_MT_MAX_HORIZ_SEGMENT_LENGTH_LEFT IMAQ_MT_MAX_HORIZ_SEGMENT_LENGTH_RIGHT IMAQ_MT_MAX_HORIZ_SEGMENT_LENGTH_ROW IMAQ_MT_MOMENT_OF_INERTIA_XX IMAQ_MT_MOMENT_OF_INERTIA_XY IMAQ_MT_MOMENT_OF_INERTIA_YY IMAQ_MT_MOMENT_OF_INERTIA_XXX IMAQ_MT_MOMENT_OF_INERTIA_XXY IMAQ_MT_MOMENT_OF_INERTIA_XYY IMAQ_MT_MOMENT_OF_INERTIA_YYY IMAQ_MT_NORM_MOMENT_OF_INERTIA_XX IMAQ_MT_NORM_MOMENT_OF_INERTIA_XY IMAQ_MT_NORM_MOMENT_OF_INERTIA_YY IMAQ Vision for LabWindows/CVI User Manual Description Y-coordinate of the start of the line segment connecting the two perimeter points that are the furthest apart X-coordinate of the leftmost pixel in...
  • Page 51 IMAQ_MT_ORIENTATION IMAQ_MT_PERIMETER IMAQ_MT_PARTICLE_AND_HOLES_AREA IMAQ_MT_RATIO_OF_EQUIVALENT_ELLIPSE_AXES IMAQ_MT_RATIO_OF_EQUIVALENT_RECT_SIDES IMAQ_MT_SUM_X IMAQ_MT_SUM_Y © National Instruments Corporation Chapter 4 Performing Particle Analysis Description Normalized moment of inertia in the x direction three times Normalized moment of inertia in the x direction twice and the y direction...
  • Page 52 Chapter 4 Performing Particle Analysis Table 4-1. Particle Measurements (Continued) Measurement IMAQ_MT_SUM_XX IMAQ_MT_SUM_XY IMAQ_MT_SUM_YY IMAQ_MT_SUM_XXX IMAQ_MT_SUM_XXY IMAQ_MT_SUM_XYY IMAQ_MT_SUM_YYY IMAQ_MT_TYPE_FACTOR IMAQ_MT_WADDEL_DISK_DIAMETER IMAQ Vision for LabWindows/CVI User Manual Description Sum of all x-coordinates squared in the particle Sum of all x-coordinates multiplied by y-coordinates in the particle Sum of all y-coordinates squared in the particle...
  • Page 53: Performing Machine Vision Tasks

    Sensor resolution, lighting, optics, vibration control, part fixture, and general environment are key components of the imaging setup. All the elements of the image acquisition chain directly affect the accuracy of the measurements. © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual...
  • Page 54: Locate Objects To Inspect

    Chapter 5 Performing Machine Vision Tasks Figure 5-1 illustrates the basic steps involved in performing machine vision inspection tasks. Diagram items enclosed with dashed lines are optional steps. Note Locate Objects to Inspect In a typical machine vision application, you extract measurements from ROIs rather than the entire image.
  • Page 55 Some machine vision functions take this output and adjust the regions of inspection automatically. You can also use these outputs to programmatically move the regions of inspection relative to the object. © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual...
  • Page 56: Using Edge Detection To Build A Coordinate Transform

    Chapter 5 Performing Machine Vision Tasks Using Edge Detection to Build a Coordinate Transform You can build a coordinate transform using two edge detection techniques. one rectangular region. Use coordinate system using two independent rectangular regions. Follow these steps to build a coordinate transform using edge detection. Note To use this technique, the object cannot rotate more than ±65°...
  • Page 57 1 Primary Search Area 2 Secondary Search Area © National Instruments Corporation If you use imaqFindTransformRects() rectangular objects, each containing one separate, straight boundary of the object, as shown in Figure 5-3. The boundaries cannot be parallel. The regions must be large enough to include the boundaries in all the images you want to inspect.
  • Page 58: Using Pattern Matching To Build A Coordinate Transform

    Chapter 5 Performing Machine Vision Tasks Using Pattern Matching to Build a Coordinate Transform You can build a coordinate transform using pattern matching. Use imaqFindTransformPattern() the location of a reference feature. Use this technique when the object under inspection does not have straight, distinct edges. Complete the following steps to build a coordinate reference system using pattern matching.
  • Page 59: Choosing A Method To Build The Coordinate Transform

    Build a coordinate transformation based on edge detection using a single search area. © National Instruments Corporation The object contains a second distinct edge not parallel to the main axis in a separate search area. Object positioning accuracy better than ±5 degrees.
  • Page 60: Set Search Areas

    Chapter 5 Performing Machine Vision Tasks Set Search Areas You use ROIs to define search areas in your images and limit the areas in which you perform your processing and inspection. You can define ROIs interactively or programmatically. Defining Regions Interactively Complete the following steps to interactively define an ROI: You can also use define ROIs.
  • Page 61: Defining Regions Programmatically

    Use the edge detection tools to identify and locate sharp discontinuities in an image. Discontinuities typically represent abrupt changes in pixel intensity values, which characterize the boundaries of objects. © National Instruments Corporation Specify the contours of the ROI. Specify individual structures by providing basic parameters that describe the region you want to define.
  • Page 62: Finding Lines Or Circles

    Chapter 5 Performing Machine Vision Tasks Finding Lines or Circles If you want to find points along the edge of an object and find a line describing the edge, use imaqFindConcentricEdges() edges based on rectangular search areas, as shown in Figure 5-5. The imaqFindConcentricEdge() search areas.
  • Page 63: Finding Edge Points Along One Search Contour

    Finding Edge Points Along One Search Contour a contour. Using edge, or all edges along the contour. Use image contains little noise and the object and background are clearly differentiated. Otherwise, use © National Instruments Corporation Figure 5-6. Finding a Circular Feature imaqFindEdge() imaqFindConcentricEdge() imaqSelectAnnulus()
  • Page 64: Finding Edge Points Along Multiple Search Contours

    Chapter 5 Performing Machine Vision Tasks These functions require you to input the coordinates of the points along the search contour. Use the edge of each contour in an ROI. If you have a straight line, use imaqGetPointsOnLine() using an ROI. These functions determine the edge points based on their contrast and slope.
  • Page 65: Finding Points Using Pattern Matching

    These factors are critical in creating a template image: symmetry, feature detail, positional information, and background information. © National Instruments Corporation Define a template image in the form of a reference or fiducial pattern. Use the reference pattern to train the pattern matching algorithm with imaqLearnPattern2() Define an image or an area of an image as the search area.
  • Page 66: Feature Detail

    Chapter 5 Performing Machine Vision Tasks Symmetry A rotationally symmetric template, shown in Figure 5-7a, is less sensitive to changes in rotation than one that is rotationally asymmetric, shown in Figure 5-7b. A rotationally symmetric template provides good positioning information but no orientation information. Feature Detail A template with relatively coarse features, shown in Figure 5-8a, is less sensitive to variations in size and rotation than a model with fine features,...
  • Page 67: Background Information

    If you do not expect the instance of the template in the image to rotate or change its size, then the pattern matching algorithm has to learn only those features from © National Instruments Corporation 5-15 IMAQ Vision for LabWindows/CVI User Manual...
  • Page 68: Defining A Search Area

    Chapter 5 Performing Machine Vision Tasks the template that are necessary for shift-invariant matching. However, if you want to match the template at any orientation, use rotation-invariant matching. Use the learningMode parameter of to specify which type of learning mode to use. The learning process is usually time intensive because the algorithm attempts to find the optimum features of the template for the particular matching process.
  • Page 69: Setting Matching Parameters And Tolerances

    Otherwise, set the mode element to IMAQ_MATCH_ROTATION_INVARIANT Shift-invariant matching is faster than rotation-invariant matching. Note © National Instruments Corporation Figure 5-11. Selecting a Search Area for Grayscale Pattern Matching imaqMatchPattern2() 5-17 Chapter 5 Performing Machine Vision Tasks...
  • Page 70: Testing The Search Algorithm On Test Images

    Chapter 5 Performing Machine Vision Tasks Minimum Contrast The pattern matching algorithm ignores all image regions in which contrast values fall below a set minimum contrast value. Contrast is the difference between the smallest and largest pixel values in a region. Set the minContrast control to slightly below the contrast value of the search area with the lowest contrast.
  • Page 71: Using A Ranking Method To Verify Results

    Color pattern matching returns the location of the center of the template and the template orientation. Complete the following general steps to find features in an image using color pattern matching: © National Instruments Corporation structure to get the position and the bounding rectangle of element of the...
  • Page 72: Defining And Creating Good Color Template Images

    Chapter 5 Performing Machine Vision Tasks Defining and Creating Good Color Template Images The selection of a good template image plays a critical part in obtaining accurate results with the color pattern matching algorithm. Because the template image represents the color and the pattern that you want to find, make sure that all the important and unique characteristics of the pattern are well defined in the image.
  • Page 73: Training The Color Pattern Matching Algorithm

    The learning process is time-intensive because the algorithm attempts to find unique features of the template that allow for fast, accurate matching. However, you can train the pattern matching algorithm offline, and save the template image using imaqWriteVisionFile() © National Instruments Corporation 5-21 IMAQ Vision for LabWindows/CVI User Manual...
  • Page 74: Defining A Search Area

    Chapter 5 Performing Machine Vision Tasks Defining a Search Area Two equally important factors define the success of a color pattern matching algorithm—accuracy and speed. You can define a search area to reduce ambiguity in the search process. For example, if your image has multiple instances of a pattern and only one instance is required for the inspection task, the presence of additional instances of the pattern can produce incorrect results.
  • Page 75: Setting Matching Parameters And Tolerances

    Use the matching algorithm. The search strategy controls the step size, sub-sampling factor, and percentage of color information used from the template. © National Instruments Corporation to set these elements. element to control the granularity of the color sensitivity IMAQ_SENSITIVITY_LOW .
  • Page 76 Chapter 5 Performing Machine Vision Tasks Choose from the following search strategies: • Note Use the IMAQ_CONSERVATIVE close to each other in the image. • • • Color Score Weight When you search for a template using both color and shape information, the color and shape scores generated during the match process are combined to generate the final color pattern matching score.
  • Page 77: Testing The Search Algorithm On Test Images

    • • Complete the following general steps to find features in an image using color location. © National Instruments Corporation Setting Matching Parameters and Tolerances imaqMatchColorPattern() Requires the location and the number of regions in an image with their specific color information...
  • Page 78: Convert Pixel Coordinates To Real-World Coordinates

    Chapter 5 Performing Machine Vision Tasks You can save the template image using Convert Pixel Coordinates to Real-World Coordinates The measurement points you located with edge detection and pattern matching are in pixel coordinates. If you need to make measurements using real-world units, use the pixel coordinates into real-world units.
  • Page 79: Analytic Geometry Measurements

    © National Instruments Corporation —Fits a line to a set of points and computes the imaqFitLine() equation of the line.
  • Page 80: Identify Parts Under Inspection

    Before you classify objects, you must train the classifier session with samples of the objects using the NI Classification Training Interface. Go to Start»Programs»National Instruments»Classification Training to launch the NI Classification Training Interface. After you have trained samples of the objects you want to classify, use the...
  • Page 81: Reading Characters

    Before you read text and/or characters in an image, you must train the OCR Session with samples of the characters using the NI OCR Training Interface. Go to Start»Programs»National Instruments»Vision»OCR Training to launch the OCR Training Interface. After you have trained samples of the characters you want to read, use the following functions to read the characters: ©...
  • Page 82: Reading Barcodes

    Chapter 5 Performing Machine Vision Tasks Reading Barcodes Use barcode reading functions to read values encoded into 1D barcodes, Data Matrix barcodes, and PDF417 barcodes. Reading 1D Barcodes To read a 1D barcode, locate the barcode in the image using one of the techniques described in this chapter.
  • Page 83: Reading Pdf417 Barcodes

    The overlay appears every time you display the image in an external window. © National Instruments Corporation imaqReadDataMatrixBarcode() element of the options parameter to...
  • Page 84 Chapter 5 Performing Machine Vision Tasks Use the following functions to overlay search regions, inspection results, and other information, such as text and bitmaps. • • • • • • • • • • To use these functions, pass in the image on which you want to overlay information and the information that you want to overlay.
  • Page 85 As with calibration information, overlay information is removed from an image Note when the image size or orientation changes. © National Instruments Corporation , and imaqFindTransformPattern() The search area input into the function The search lines used for edge detection...
  • Page 86: Calibrating Images

    Then, depending on your needs, you can do one of the following: • • © National Instruments Corporation Define a calibration template. Define a reference coordinate system. Learn the calibration information. Use the calibration information to convert pixel coordinates to real-world coordinates without correcting the image.
  • Page 87: Defining A Calibration Template

    • 1 Center-to-Center Distance Note Click Start»Programs»National Instruments»Vision»Documentation» Calibration Grid to use the calibration grid installed with IMAQ Vision. The dots have radii of 2 mm and center-to-center distances of 1 cm. Depending on your printer, these measurements may change by a fraction of a millimeter. You can purchase highly accurate calibration grids from optics suppliers, such as Edmund Industrial Optics.
  • Page 88: Defining A Reference Coordinate System

    If you specify a grid for the calibration process, the software defines the following default coordinate system, as shown in Figure 6-3: © National Instruments Corporation Figure 6-2. Axis Direction in the Image Plane The origin is placed at the center of the left, topmost dot in the calibration grid.
  • Page 89 Chapter 6 Calibrating Images 1 Origin of a Calibration Grid in the Real World If you specify a list of points instead of a grid for the calibration process, Note the software defines a default coordinate system, as follows: The origin is placed at the point in the list with the lowest x-coordinate value and then the lowest y-coordinate value.
  • Page 90: Learning Calibration Information

    If you want to specify a list of points instead of a grid, use imaqLearnCalibrationPoints() CalibrationPoints © National Instruments Corporation Figure 6-4. Defining a Coordinate System Acquire or Read an Image Images. The grid does not need to occupy the entire imaqLearnCalibrationGrid() to learn the calibration information.
  • Page 91: Specifying Scaling Factors

    Chapter 6 Calibrating Images Specifying Scaling Factors Scaling factors are the real-world distances between the dots in the calibration grid in the x and y directions and the units in which the distances are measured. Use the factors. Choosing a Region of Interest Define a learning ROI during the learning process to define a region of the calibration grid you want to learn.
  • Page 92: Using The Learning Score

    Note A high score does not reflect the accuracy of your system. © National Instruments Corporation element of the options parameter to mode to choose the perspective calibration algorithm.
  • Page 93: Learning The Error Map

    Chapter 6 Calibrating Images If the learning process returns a learning score below 600, try the following: Learning the Error Map An error map helps you gauge the quality of your complete system. The error map returns an estimated error range to expect when a pixel coordinate is transformed into a real-world coordinate.
  • Page 94: Simple Calibration

    Use the method parameter to set the scaling method. Set the learnTable parameter to correction table. 1 Origin © National Instruments Corporation Figure 6-7. Defining a Simple Calibration IMAQ Vision for LabWindows/CVI User Manual Chapter 6...
  • Page 95: Save Calibration Information

    Chapter 6 Calibrating Images Save Calibration Information After you learn the calibration information, you can save it so that you do not have to relearn the information for subsequent processing. Use imaqWriteVisionFile() calibration information to a file. To read the file containing the calibration information use Calibration Information section of this chapter for more information about attaching the calibration information you read from another image.
  • Page 96: Technical Support And Professional Services

    Technical Support and Professional Services Visit the following sections of the National Instruments Web site at ni.com • • • If you searched your local office or NI corporate headquarters. Phone numbers for our worldwide offices are listed at the front of this manual. You also can visit...
  • Page 97 Numbers One-dimensional. Two-dimensional. Three-dimensional. AIPD The National Instruments internal image file format used for saving complex images and calibration information associated with an image (extension APD). alignment The process by which a machine vision application determines the location, orientation, and scale of a part being inspected.
  • Page 98 Glossary barycenter The grayscale value representing the centroid of the range of an image’s grayscale values in the image histogram. binary image An image in which the objects usually have a pixel intensity of 1 (or 255) and the background has a pixel intensity of 0. binary morphology Functions that perform morphological operations on a binary image.
  • Page 99 FFT plane are encoded in 64-bit floating-point values: 32 bits for the real part and 32 bits for the imaginary part. connectivity Defines which of the surrounding pixels of a given pixel constitute its neighborhood. © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual Glossary...
  • Page 100 Glossary connectivity-4 Only pixels adjacent in the horizontal and vertical directions are considered neighbors. connectivity-8 All adjacent pixels are considered neighbors. contrast A constant multiplication factor applied to the luma and chroma components of a color pixel in the color decoding process. convex hull The smallest convex polygon that can encapsulate a particle.
  • Page 101 The nonlinear change in the difference between the video signal’s brightness level and the voltage level needed to produce that brightness. gradient convolution filter © National Instruments Corporation histogram equalization. gradient filter. center of mass.
  • Page 102 Glossary gradient filter An edge detection algorithm that extracts the contours in gray-level values. Gradient filters include the Prewitt and Sobel filters. gray level The brightness of a pixel in an image. gray-level dilation Increases the brightness of pixels in an image that are surrounded by other pixels with a higher intensity.
  • Page 103 The number of values a pixel can take on, which is the number of colors or shades that you can see in the image. image display A window or control that displays an image. environment © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual Glossary...
  • Page 104 Glossary image enhancement The process of improving the quality of an image that you acquire from a sensor in terms of signal-to-noise ratio, image contrast, edge definition, and so on. image file A file containing pixel data and additional information about the image. image format Defines how an image is stored in a file.
  • Page 105 LabVIEW Laboratory Virtual Instrument Engineering Workbench. A program development environment application based on the programming language G used commonly for test and measurement applications. LabWindows/CVI Windows/Sun Product. © National Instruments Corporation IMAQ Vision for LabWindows/CVI User Manual Glossary...
  • Page 106 Glossary line gauge Measures the distance between selected edges with high-precision subpixel accuracy along a line in an image. For example, this function can be used to measure distances between points and edges. This function also can step and repeat its measurements across the image. line profile Represents the gray-level distribution along a line of pixels in an image.
  • Page 107 They are used primarily to delineate objects and prepare them for quantitative inspection analysis. M-skeleton function Uses an M-shaped structuring element in the skeleton function. © National Instruments Corporation G-11 IMAQ Vision for LabWindows/CVI User Manual Glossary , when used with...
  • Page 108 Operations on a point in an image that take into consideration the values of operations the pixels neighboring that point. NI-IMAQ The driver software for National Instruments IMAQ hardware. nonlinear filter Replaces each pixel value with a nonlinear function of its surrounding pixels.
  • Page 109 Directly calibrates the physical dimensions of a pixel in an image. pixel depth The number of bits used to represent the gray level of a pixel. © National Instruments Corporation G-13 IMAQ Vision for LabWindows/CVI User Manual Glossary...
  • Page 110 Glossary Portable Network Graphic. An image file format for storing 8-bit, 16-bit, and color images with lossless compression. PNG images have the file extension PNG. Prewitt filter An edge detection algorithm that extracts the contours in gray-level values using a 3 × 3 filter kernel. proper-closing A finite combination of successive closing and opening operations that you can use to fill small holes and smooth the boundaries of objects.
  • Page 111 An edge detection algorithm that extracts the contours in gray-level values using a 3 × 3 filter kernel. spatial calibration Assigns physical dimensions to the area of a pixel in an image. © National Instruments Corporation G-15 IMAQ Vision for LabWindows/CVI User Manual Glossary...
  • Page 112 Glossary spatial filters Alter the intensity of a pixel relative to variations in intensities of its neighboring pixels. You can use these filters for edge detection, image enhancement, noise reduction, smoothing, and so forth. spatial resolution The number of pixels in an image, in terms of the number of rows and columns in the image.
  • Page 113 PC, that has the functionality of a classic stand-alone instrument. (2) A LabVIEW software module (VI), which consists of a front panel user interface and a block diagram program. © National Instruments Corporation G-17 IMAQ Vision for LabWindows/CVI User Manual...
  • Page 114 1D barcodes, 5-30 reading data matrix barcodes, 5-30 reading PDF417 barcodes, 5-31 binary images creating, 4-1 improving, 4-2 © National Instruments Corporation calibrating images, 6-1 imaging systems, 2-2 calibration defining templates, 6-2 saving calibration information, 6-10 using simple calibration, 6-9...
  • Page 115 Index color information learning, 3-9 specifying, 3-9 color location, using to find points, 5-25 color representation sensitivity, specifying, 3-12 color score weight, 5-24 comparing, color content in images, 3-9 computing energy center of an image, 3-7 energy center of an ROI in an image, 3-7 configuring, tools palette, 3-6 conventions used in the manual, ix converting...
  • Page 116 IMAQ Vision, 1-2 getting center of energy for an image, 3-7 image statistics, 3-7 grayscale morphology, 2-11 grayscale statistics, measuring, 3-7 © National Instruments Corporation help, technical support, A-1 highpass attenuation, 2-13 filters, 2-10 truncation, 2-13 holes, filling in particles, 4-3...
  • Page 117 Index improving binary images, 4-2 improving sharpness of transitions, 2-10 inspecting, 2-8 learning color information, 3-9 learning the color distribution, 3-10 loading from file, 2-5 measuring light intensity, 3-7 modifying complex images, 2-13 processing components, 3-7 reading, 2-5 reading from file, 2-6 setting color sensitivity, 5-23 source, 2-4 taking color measurements, 3-1...
  • Page 118 National Instruments support and services, A-1 NI Vision Assistant, x NI Vision Builder for Automated Inspection, x NI-IMAQ, xi Nth order filter, 2-11 objects, 5-2 inspecting, 5-2 locating, 5-2 open operation, 4-3 opening, particles, 4-3 particle analysis, performing, 4-1 particles, 4-1...
  • Page 119 Index search algorithm, testing, 5-18, 5-25 search areas, 5-10 defining, 5-16, 5-22 ROIs, defining search areas, 5-8 search strategies, selecting for pattern matching, 5-23 selecting, pattern matching search strategies, 5-23 separating, touching particles, 4-3 setting color sensitivity, 5-23 pattern matching tolerances, 5-23 scaling methods, 6-8 setting up, imaging systems, 2-1 shifting, ROIs, 5-2...

This manual is also suitable for:

Imaq vision

Table of Contents