## 2 Methodology
### Shape Feature Analysis and Flow of Feature Shape Region Searching Algorithm  
#### 2.2.1 Shape Feature Analysis  
As shown in Figure 4, several shapes are extracted from a printed image after the preliminary shape extraction process (Section 2.2.2). The shape in Figure 4a is mainly composed of several horizontal lines. These shapes are often included in the edges of graphics or in the complicated strokes of the characters in graphics-rich printed matter. Hence, this type of registration region shape is likely to cause a mismatch. The shape in Figure 4b belongs to a segment of a barcode. The shape feature is not obvious, and it is surrounded by many similar shapes, which could cause a mismatch. The shape in Figure 4c consists of the numeral 2 and a horizontal line. The contour of the numeral 2 is relatively regular and highly recognizable and may thus be an ideal shape feature. By contrast, the horizontal line  
Figure 3: Flowchart of online printing defect inspection.  
contains little characteristic information and is almost meaningless for shape matching. In addition, it increases time consumption and is consequently undesirable. Other shapes are formed by the boundaries of the two patterns. The shape shown in Figure 4d is common in texture-rich printed matter; it is irregular and can easily cause a mismatch. On the contrary, the shape region shown in Figure 4e is a Chinese character \"period\" with obvious features, regular contours, and high degree of recognition feature. Thus, it is a good shape region for image registration during printed image defect detection.  
No research or strict definition describes the ideal shape for registration in printing defect inspection. Considering the requirements of the automatic searching of registration feature regions in online printing defect inspection, we innovatively propose a description of an ideal shape. It preferably contains the following three elements:  
1. The ideal shape should be a completely closed contour, that is, the contour points should be distributed in all direction bins.
2. The closed shape contour should include approximately vertical and horizontal line points, that is, the gradient directions of 0\({}^{\circ}\), 90\({}^{\circ}\), 180\({}^{\circ}\), and 270\({}^{\circ}\) have abundant edge points.
3. Aside from the vertical and horizontal edge points, a good shape contour should have rich edge gradient information. In addition to the edge points in the horizontal and vertical directions, the shape contour should have many changes in contour edge direction and shape. The distribution of edge points in each gradient direction should be uniform.  
The analysis shows that the feature region for printed image registration requires a completely closed contour shape, a rich contour edge gradient direction, horizontal and vertical lines, and so on. Therefore, we conclude that regions containing any one shape, such as quasi-rectangle, ellipse-like shapes, or a shape with numerous changes in edge direction, can be used as a feature region for image registration. This feature region should be easy to identify and exhibit strong robustness. This study proposes an automatic shape feature region detection algorithm that can detect quasi-rectangle, ellipse-like shapes, etc. The results should address the inaccurate and time-consuming problems of the manual selection of registration feature regions.