Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 6, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

Machine Vision and Vision Analysis in Visual Basic

7 ratings | 2.71 out of 5
Print

Overview

National Instruments Vision for Measurement Studio includes CWIMAQVision, which controls image analysis. Measurement Studio 6.0 includes cwmv.ocx, which is a new machine vision ActiveX control. This control builds on the CWIMAQVision methods and properties, providing high-level machine vision functionality.

Analysis (CWIMAQVision)

Placing a CWIMAQVision control on a form gives you access to hundreds of functions, such as thresholding, blob analysis, pattern matching, and so on.

The following example shows how to threshold an image and display it next to the original grayscale image. This is the function call for the thresholding process:

CWIMAQVision.Threshold ( SourceImage, DestImage [, MinValue = 128] [, MaxValue = 255] [, DoReplacement = True] [, NewValue = 1])

Private Sub Read_Click()
' Attach the image to the viewer.
CWIMAQViewer1.Attach CWIMAQ1.Images(1)
' Acquire the image.
CWIMAQ1.AcquireImage
' Threshold the image.
CWIMAQVision1.Threshold CWIMAQViewer1.Image,CWIMAQViewer2.Image, 128, 255, TRUE, 255
End Sub

This example produces results similar to the following illustration.



The following code shows how to create a report that holds the results of an operation.

Dim HistReport as New CWIMAQHistogramReport
CWIMAQVision1.Histogram MyImage, HistReport

HistReport contains data about area, mean, standard deviation, pixel range, and so on.

Where to find examples:
C:\Program Files\National Instruments\NI-IMAQ\Sample\VB\Processing
C:\Program Files\National Instruments\MeasurementStudio\VB\Samples\IMAQ\2. Functions
C:\Program Files\National Instruments\MeasurementStudio\VB\Samples\IMAQ\3. Applications

Machine Vision (CWMachineVision)


The CWMachineVision control is a separate ActiveX control that you add to a project in addition to the CWIMAQVision control. To add the control, click Project»Components»Controls»National Instruments Machine Vision 6.0.

The CWMachineVision control provides high-level functionality that builds on the CWIMAQVision functions. The source code for the machine vision methods is located in Measurement Studio»VB»Source»MachineVision, where Measurement Studio is the location in which you installed Measurement Studio. Review the source code to see how the high-level algorithms work.

Refer to Getting Results with ComponentWorks IMAQ Vision for a detailed example of how to use the machine vision methods to find features on an image.

Refer to the IMAQ Vision for Visual Basic Reference help file for information about CWMachineVision and CWIMAQVision properties, methods, and events. To access the help file, right-click an IMAQ control and click Help, or click Start»Programs»National Instruments»Vision»Documentation»IMAQ Vision 6.0 for Visual Basic Reference.

Where to find examples:
C:\Program Files\National Instruments\MeasurementStudio\VB\Samples\IMAQ\2. Functions
C:\Program Files\National Instruments\MeasurementStudio\VB\Samples\IMAQ\3. Applications
7 ratings | 2.71 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).