(Binary) shape matching is a tool that can be used if a Machine Vision application has to detect corresponding or similar shapes ; for example, if different parts in a production process have to be sorted or defective parts should be detected .
The image, which is the base for the shape matching process, has to be binary; so it has to be converted from a gray-level or color image. An example is on the attached CD-ROM; the color image is called shapes1.png . The following script can be used to convert the image to a binary one.
Figure 5.53. Shape Matching with IMAQ Vision Builder
IMAQ Vision Builder 6.0 List of functions generated : Tuesday, 15. October 2002 14:15 STEP #1 Extract Color Planes : HSL “ Saturation Plane IMAQ Vision VI IMAQ ExtractSingleColorPlane C Function imaqExtractColorPlanes Visual Basic Methods CWIMAQVision.ExtractColorPlanes Parameters: Color Plane Long (I32) 4 STEP #2 Threshold : Manual Threshold IMAQ Vision VI IMAQ Threshold C Function imaqThreshold Visual Basic Methods CWIMAQVision.Threshold Parameters: Range.Lower value Float (SGL) 34,133858 Range.Upper value Float (SGL) 255,000000 IMAQ Vision VI IMAQ Cast Image C Function imaqCast Visual Basic Methods CWIMAQVision.Cast Parameters: Image Type Long (I32) 0 Connections: Connect output "Image Dst Out" of "IMAQ Threshold" to input "Image Src" of "IMAQ Cast Image". Connect output "error out" of "IMAQ Threshold" to input "error in (no error)" of "IMAQ Cast Image". Comment: Display your image with a Binary palette.
Figure 5.53 shows a shape matching result of the shapes image. The entire process is divided into two parts:
You can try this example with a number of different templates. Note that the conversion from color to gray-level uses the saturation plane of the HSL color model, leading to optimal results in the subsequent threshold operation.
Pattern Matching |
Introduction and Definitions
Image Acquisition
Image Distribution
Image Processing
Image Analysis
About the CD-ROM