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.
IMAQ Vision objects, methods, properties, or events while creating your application, refer to this help file. You can access this file by selecting Start»Programs»National Instruments» Documentation»Vision»IMAQ Vision for Visual Basic Reference. NI Vision Assistant Tutorial—If you need to install NI Vision Assistant and learn the fundamental features of the software, follow the instructions in this tutorial.
Page 10
Vision\Examples\MSVB.NET 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 .
Access this file from within Visual Basic or from the Start menu by selecting Programs»National Instruments»Vision» Documentation. NI-IMAQ User Manual—If you have a National Instruments image acquisition (IMAQ) device and need information about the functions that control the IMAQ device, refer to this portable document (PDF) file which was installed at the following location when you installed NI-IMAQ: Start»Programs»National Instruments»Vision»...
Chapter 1 Introduction to IMAQ Vision niocr.ocx niocr.ocx objects you use in a machine vision application to perform optical character recognition (OCR). NIOCR control Use this control to perform OCR, which is the process by which the machine vision software reads text and/or characters in an image. OCR consists of the following two procedures: •...
Dim image As New CWIMAQImage If you intend to develop an application in Visual C++, National Instruments recommends that you use IMAQ Vision for LabWindows/CVI. However, if you decide...
Page 16
Chapter 1 Introduction to IMAQ Vision Measurement-Ready IMAQ Vision for Visual Basic User Manual Set Up Your Imaging System Calibrate Your Imaging System Create an Image Acquire or Read an Image Chapter 2: Getting Images Display an Image Attach Calibration Information Analyze an Image Improve an Image Improve an Image...
IMAQ devices. ni.com/imaq Configure the driver software for the image acquisition device. If you have a National Instruments image acquisition device, configure the NI-IMAQ driver software through Measurement & Automation Explorer (MAX). Open MAX by double-clicking the Measurement &...
Acquiring an Image Use the CWIMAQ control to acquire images with a National Instruments IMAQ device. You can use IMAQ Vision for Visual Basic to perform one-shot and continuous acquisitions. You can choose the acquisition type during design time by setting the value of the Acquisition Type combo box to One-Shot or Continuous.
Chapter 2 Getting Measurement-Ready Images Private Sub Stop_Click() End Sub Reading a File Use the a file stored on the computer into the image reference. You can read from image files stored in several standard formats, such as BMP, TIFF, JPEG, PNG, and AIPD.
Page 25
Chapter 2 Getting Measurement-Ready Images distribution in the image. Use the histogram of the image to analyze two important criteria that define the quality of an image—saturation and contrast. If the image does not have enough light, the majority of the pixels will have low intensity values, which appear as a concentration of peaks on the left side of the histogram.
Chapter 2 Getting Measurement-Ready Images Highpass filters emphasize details, such as edges, object boundaries, or cracks. These details represent sharp transitions in intensity value. You can define your own highpass filter with CWIMAQVision.NthOrder filter with CWIMAQVision.CannyEdgeFilter allows you to find edges in an image using predefined edge detection kernels, such as the Sobel, Prewitt, and Roberts kernels.
Chapter 2 Getting Measurement-Ready Images Complex Image Operations CWIMAQVision.ReplaceComplexPlane CWIMAQVision.ExtractComplexPlane and update independently the magnitude, phase, real, and imaginary planes of a complex image. You can also convert a complex image to an array and back with CWIMAQImage.ArrayToImage IMAQ Vision for Visual Basic User Manual Improve the image in the frequency domain with a lowpass or highpass frequency filter.
Page 31
Chapter 3 Making Grayscale and Color Measurements None Selection Tool Point Line Rectangle Rotated Rectangle Oval Annulus Broken Line IMAQ Vision for Visual Basic User Manual Table 3-1. Tools Palette Functions Tool Name Disable the tools. Select an ROI in the image and adjust the position of its control points and contours.
Page 33
Chapter 3 Making Grayscale and Color Measurements 1 Anchoring Coordinates of a Region of Interest 2 Size of the Image 3 Zoom Factor 4 Image Type Indicator (8-bit, 16-bit, Float, RGB32, RGBU64, HSL, Complex) IMAQ Vision for Visual Basic User Manual 5 Pixel Intensity 6 Coordinates of the Mouse 7 Size of an Active Region of Interest...
Chapter 3 Making Grayscale and Color Measurements CWIMAQRegion contains. When you know the type of shape that the region contains, you can set the region into a shape variable and use that variable to manipulate the shape properties. For example, the following code resizes a rectangle selected on the viewer: Dim MyRectangle As CWIMAQRectangle Set MyRectangle = CWIMAQViewer1.Regions(1)
Page 37
Chapter 3 Making Grayscale and Color Measurements Green Blue Saturation Color Intensity Image Saturation Luminance Saturation Value Color Image A color pixel encoded as a individual components using You can convert a pixel value represented in any color model into its components in any other color model using CWIMAQVision.ColorValueConversion2 IMAQ Vision for Visual Basic User Manual...
Chapter 3 Making Grayscale and Color Measurements Specifying the Color Information to Learn Because color matching only uses color information to measure similarity, the image or regions in the image representing the object should contain only the significant colors that represent the object, as shown in Figure 3-5a.
Chapter 3 Making Grayscale and Color Measurements fuses much better and results in high match scores—around 800—for both the fuses. You can use an unlimited number of samples to learn the representative color spectrum for a specified template. 1 Regions used to learn color information Choosing a Color Representation Sensitivity When you learn a color, you need to specify the granularity required to specify the color information.
Chapter 4 Performing Particle Analysis If all the objects in the grayscale image are either brighter or darker than the background, you can use automatically determine the optimal threshold range and threshold the image. Automatic thresholding techniques offer more flexibility than simple thresholds based on fixed ranges.
Chapter 4 Performing Particle Analysis Improving Particle Shapes CWIMAQVision.Morphology particles. You can use the Open, Close, Proper Open, Proper Close, and auto-median operations to smooth the boundaries of the particles. Open and Proper Open Smooth the boundaries of the particle by removing small isthmuses, while close widens the isthmuses.
Page 50
Chapter 4 Performing Particle Analysis Measurement cwimaqMeasurementMaxFeretDiameterStartY cwimaqMeasurementMaxHorizSegmentLengthLeft cwimaqMeasurementMaxHorizSegmentLengthRight cwimaqMeasurementMaxHorizSegmentLengthRow cwimaqMeasurementMomentOfInertiaXX cwimaqMeasurementMomentOfInertiaXXX cwimaqMeasurementMomentOfInertiaXXY cwimaqMeasurementMomentOfInertiaXY cwimaqMeasurementMomentOfInertiaXYY cwimaqMeasurementMomentOfInertiaYY cwimaqMeasurementMomentOfInertiaYYY cwimaqMeasurementNormMomentOfInertiaXX cwimaqMeasurementNormMomentOfInertiaXXX cwimaqMeasurementNormMomentOfInertiaXXY IMAQ Vision for Visual Basic User Manual Table 4-1. Measurement Types (Continued) Y-coordinate of the start of the line segment connecting the two perimeter points that are the furthest apart.
Page 52
Chapter 4 Performing Particle Analysis Measurement cwimaqMeasurementSumXXY cwimaqMeasurementSumXY cwimaqMeasurementSumXYY cwimaqMeasurementSumY cwimaqMeasurementSumYY cwimaqMeasurementSumYYY cwimaqMeasurementTypesFactor cwimaqMeasurementWaddelDiskDiameter IMAQ Vision for Visual Basic User Manual Table 4-1. Measurement Types (Continued) The sum of all X-coordinates squared times Y-coordinates in the particle. The sum of all X-coordinates times Y-coordinates in the particle.
Chapter 5 Performing Machine Vision 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 regions of interest rather than the entire image. To use this technique, the parts of the object you are interested in must always appear inside the regions of interest you define.
Page 56
Chapter 5 Performing Machine Vision Tasks 1 Search Area for the Coordinate System 2 Object Edges IMAQ Vision for Visual Basic User Manual 3 Origin of the Coordinate System 4 Measurement Area Figure 5-2. Coordinate Systems of a Reference Image and Inspection Image If you use CWMachineVision.FindCoordTransformUsingTwoRects specify two rectangular ROIs, each containing one separate,...
Page 58
Chapter 5 Performing Machine Vision Tasks IMAQ Vision for Visual Basic User Manual Define a template that represents the part of the object that you want to use as a reference feature. For more information about defining a template, refer to the Find Measurement Points Define a rectangular search area in which you expect to find the template.
Chapter 5 Performing Machine Vision Tasks Set Search Areas Select ROIs in the images to limit the areas in which you perform the processing and inspection. You can define ROIs interactively or programmatically. Defining Regions Interactively Follow these steps to interactively define an ROI: You also can use the techniques described in Chapter 3, and Color Table 5-1 indicates which ROI selection methods to use with a given...
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 CWMachineVision.FindStraightEdge on rectangular search areas, as shown in Figure 5-5. CWMachineVision.FindConcentricEdge on annular search areas.
Chapter 5 Performing Machine Vision Tasks Finding Edge Points Along Multiple Search Contours Use the CWIMAQVision.ConcentricRake along multiple search contours. These methods behave like CWIMAQVision.FindEdges2 These methods find only the first edge that meets the criteria along each contour. Pass in a CWIMAQRegions object to define the search region for these methods.
Page 66
Chapter 5 Performing Machine Vision Tasks 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. a Good Feature Detail Positional Information A template with strong edges in both the x and y directions is easier to locate.
Chapter 5 Performing Machine Vision Tasks Defining a Search Area Two equally important factors define the success of a pattern matching algorithm: accuracy and speed. You can define a search area to reduce ambiguity in the search process. For example, if the image has multiple instances of a pattern and only one of them is required for the inspection task, the presence of additional instances of the pattern can produce incorrect results.
Chapter 5 Performing Machine Vision Tasks Minimum Contrast Contrast is the difference between the smallest and largest pixel values in a region. You can set the minimum contrast to potentially increase the speed of the pattern matching algorithm. The pattern matching algorithm ignores all image regions where contrast values fall beneath a set minimum contrast value.
Chapter 5 Performing Machine Vision Tasks Defining and Creating Effective Color Template Images The selection of a effective 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 the 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 Use one of the following four search strategies: • • • • Use the conservative strategy if you have multiple targets located very close to each Note other in the image. Decide on the best strategy by experimenting with the different options. a search strategy.
Chapter 5 Performing Machine Vision Tasks • • Complete the following steps to find features in an image using color location: image. 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 CWIMAQVision.ConvertPixelToRealWorldCoordinates the pixel coordinates into real-world units.
Chapter 5 Performing Machine Vision Tasks • • Instrument Reader Measurements You can make measurements based on the values obtained by meter, LCD, and barcode readers. CWIMAQMeterArc.CreateFromLines gauge that you want to read. calibrates the meter using the initial position and the full-scale position of the needle.
Before you classify objects, you must create a classifier file 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 following methods to classify the image under inspection: •...
Chapter 5 Performing Machine Vision Tasks types: Codabar, Code 39, Code 93, Code 128, EAN 8, EAN 13, Interleaved 2 of 5, MSI, and UPCA. Read Data Matrix Barcode in a Data Matrix barcode. This method can automatically determine the location of the barcode and appropriate search options for the application.
Page 84
Chapter 5 Performing Machine Vision Tasks • • • • • • You can select the color of overlays by using one of these methods. If you do not supply a color to an overlay method, the is used. You can configure the following CWMachineVision methods to overlay different types of information about the inspection image: •...
Note You can use the calibration grid installed with IMAQ Vision at Start»Programs» National Instruments»Vision»Documentation»Calibration Grid. The dots have radii of 2 mm and center-to-center distances of 1 cm. Depending on the 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: If you define a coordinate system yourself, carefully consider the requirements of the application: •...
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 CWIMAQCalibrationGridOptions.GridDescriptor specify the scaling 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 A high score does not reflect the accuracy of the system. Note 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 the 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 1 Origin 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 CWIMAQVision.WriteImageAndVisionInfo the grid and its associated calibration information to a file. To read the file containing the calibration information use CWIMAQVision.ReadImageAndVisionInfo about attaching the calibration information you read from another image,...
Page 97
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 98
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 99
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 101
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 103
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 105
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 107
Glossary linear filter A special algorithm that calculates the value of a pixel based on its own pixel value as well as the pixel values of its neighbors. The sum of this calculation is divided by the sum of the elements in the matrix to obtain a new pixel value.
Page 109
Glossary NI-IMAQ The driver software for National Instruments IMAQ hardware. nonlinear filter Replaces each pixel value with a nonlinear function of its surrounding pixels. nonlinear A highpass edge-extraction filter that favors vertical edges. gradient filter nonlinear Prewitt filter A highpass, edge-extraction filter based on two-dimensional gradient information.
Page 111
Glossary 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. proper-opening A finite combination of successive opening and closing operations that you can use to remove small particles and smooth the boundaries of objects. quantitative analysis Obtaining various measurements of objects in an image.
Page 113
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 116
Index color pattern matching finding points, 5-19 optimize speed with search strategy, 5-23 setting rotation angle ranges, 5-25 color pattern matching algorithms training, 5-21 using contrast, 5-25 color scores, 5-24 color sensitivity, using to control granularity in template images, 5-23 color spectrums, learning, 3-10 color statistics, measuring, 3-6, 3-7 color template images, defining, 5-20...
Page 118
5-7 multiple ROIs, using to view color differences in an image, 3-11 multiple search contours, finding edge points, 5-12 National Instruments support and services, A-1 NI-IMAQ, xi niocr.ocx, 1-4 nonlinear calibration, 6-1 Nth order filter, 2-10...