Contour analysis is often used to detect defects in objects by analyzing the object's contours. Boundary curves of objects are connected to produce contours. For this purpose, the objects in the image should have clear boundary edges to accurately distinguish its location from the image background. Since boundary curves are a set of edge points, the color image should be converted to 8 bit grayscale or binary image for the edge detection.
Figure 13.1 shows the basic process for contour analysis to find defects in objects.
To analyze the contour of objects, curvature profile is often used. The curvature profile is effective in detecting defects in places where the contour changes abruptly. However, some objects may have abrupt contour changes even though there are no defects. In such cases, defect detection using the curvature may be impossible.
On the other hand, you may use a reference template image to detect defects in an object by the comparison of contours. Alternatively, if the contour has a standard geometric general shape, such as line, circle ellipse, polynomial, and B-spline, the contour of the object may be numerically fitted to find abnormal parts in an object.
The example for detecting defects of an object can be found from the following folder: