Contour refers to a group of interconnected curves that can outline the Contour of the target in an image. These curves are composed of a series of edge points of the target. A contour formed by a curve usually Outlines the Shape of the object under test. Therefore, the object contour based on extraction can not only achieve image segmentation, but also achieve machine vision applications such as size measurement, defect detection, target contour analysis, matching and contour classification.

For example, the contour of an observed object can be compared with a contour template or fitted curve to determine the presence of the object or to test its quality. It can also determine whether the target profile is qualified by detecting the key dimension information such as circumference, radius, curvature and Angle of the target profile. This kind of application often involves contour extraction, contour matching and classification.

Nl Vision provides a special set of functions for Contour extraction, Contour comparison and Contour Analysis classification. These VI are located in the selection board of Vision and Motion →Machine Vision→Contour Analysis function of LabVIEW, as shown in the figure below:

Please refer to the help manual for the function description and usage:

IMAQ Extract Contour encapsulates the Contour extraction process, including several steps of seed point search, curve tracking, curve connection and Contour selection. By IMAQ Extract Contour, the three types of target contours closest to the search starting point, with the longest length or the strongest average gradient can be selected. The extracted Contour information will be attached to the image in memory for subsequent processing.

Contour can participate in two kinds of comparison operations, one is to compare with the ideal curve based on contour pixel fitting, the other is to compare with contour template. In any case, the distance between the contour and the corresponding point on the curve or template is compared point by point, and the deviation of the measured target contour is judged according to the set distance range.

By comparing the contour of cans and the circular curve based on contour pixel fitting, and judging the quality of cans according to the maximum distance between them, to understand the use of NI Vision contour and fitting curve comparison, the program design ideas are as follows:

  • At the beginning of the program, the image file to be tested was read from the specified folder, and then IMAQ ExtractContour was used to extract the contour of the longest cans in the ring ROI.
  • IMAQ Fit Contour reads the Contour information from the file and fits a circular curve based on these points. The circular curve as a reference standard for judging qualified cans is saved in memory after the image for subsequent use;
  • IMAQ Compute Contour DistancesCan extract Contour and curve information from memory image data, and calculate the distance between them.
  • The For loop checks whether the distance between the corresponding points exceeds the set maximum and displays the distance curve. If the distance between any two points exceeds the limit, set the test result to Fail.
  • IMAQ Overlay Contour and Overlay Point withUser Specified size. vi will display the Contour in the form of lossless layer in the image and mark the Contour points whose distance exceeds the limit.

The program design is as follows:

By running the program and adjusting the delay of the While loop, you can observe the results of the program.

Project resource download: download.csdn.net/download/m0…

The target’s contour can also be compared to the contour template. Different from the process of curve fitting, the contour pattern characteristic information in the standard reference image should be collected before the comparison with the contour template, and the contour template should be generated and added to the standard reference image for future use. This process is called contour Learning process. The actual detected targets are not all the same as those in the standard reference image, but may be scaled, rotated or Occlusion, as shown below:

Therefore, in the contour learning process, besides collecting the contour information of the standard position, it is also necessary to calculate the contour information of the target in the zooming or rotation condition based on the standard reference target, so as to support the various posture of the target contour in the field of view. By default, Nl Vision supports a zoom of ±25% of the original target with 360° rotation in the field of view. The more rotation angles and scaling a program supports, the longer it will take to execute. During the design process, the rotation Angle and scaling ratio should be limited as far as possible according to the actual situation, and trade-offs should be made with the speed of the algorithm when necessary.