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 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 ...
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 • • •...
<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 .
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...
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 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...
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.
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.
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.
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.
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.
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 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 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()
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 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 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.
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.
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.
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 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 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 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...
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.
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°...
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.
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.
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.
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.
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,...
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.
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.
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.
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 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.
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.
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...
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 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.
• 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 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.
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.
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.
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.
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 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 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 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 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 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 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 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 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 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...
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