## 2 Methodology
### Shape Searching Algorithm Based on Edge Gradient Direction
The number of edge points in the vicinity of the two gradient directions (\(\pi/2\), \(3\pi/2\)) is large, that is, the numbers of edge points in the 18 th and 54 th direction or nearby sections are large. The numbers of edge points in the 36 th and 72 nd directions or nearby sections are also large, and the numbers of edge points in the other gradient directions are relatively close. In general, the histogram distribution of the edge gradient direction is relatively uniform, as  
Figure 9: Experiment results of the method based on the histogram of the edge gradient direction. (**a**) Approximate rectangular shape; (**b**) shape’s histogram of edge gradient direction; (**c**) elliptical shape; (**d**) shape’s histogram of edge gradient direction; (**e**) good shape; (**f**) shape’s histogram of edge gradient direction histogram. shown in Figure 9d, and is similar to the histogram distribution of the edge gradient direction of the quasi-elliptical shape. The values of the \(Y\) axis in Figure 9b,d,f are of a gradient magnitude, that is, the number of contour point falling into the direction bin. In addition, many shapes exhibit the characteristics of the two types of regions described previously. Figure 9e shows a good shape, which has several edge points in 18, 36, 54, and 72 gradient direction bins. In addition, the numbers of edge points in the other gradient direction bins are relatively close. In general, the histogram distribution of the edge gradient direction is relatively uniform, as shown in Figure 9f. Figure 9 shows that the aforementioned shapes have obvious features and regular contours and are thus suitable as registration feature regions. Hence, we propose to use the histogram of the edge gradient direction to detect the shape regions with rectangle, cross shape, quasi-rectangle, and quasi-cross shape types as the image registration feature regions. The detection method is defined by Formula (8):  
\[h_{i}>T_{m},\;\;i=18,\;36,54,\;72 \tag{8}\]  
where \(T_{m}\) is a threshold value used to define the number of edge points in the four gradient direction bins. Alternatively, we can select the shape region in which the overall distribution of the edge points in the gradient direction bins is relatively uniform as a feature region for image registration. The judgment conditions are as follows:  
\[\left\{ \begin{array}{l}N_{\rm g}>T_{\rm n}\\ S_{\rm g}=\rm{Deviation}(\@vec{H}_{\rm g})<T_{\rm g}\end{array} \right. \tag{9}\]  
where \(N_{g}\) is the number of directions covered by the contour points; \(T_{n}\) is the threshold of the number of directions, which limits the total number of directions in the lowest gradient and ensures that the shape has obvious features; \(S_{g}\) is the normalized standard deviation of the number of edge points in each gradient direction bin and reflects the uniformity of the distribution of edge points in each gradient direction. The size of each shape is different from the inconsistent number of edge points. Therefore, the standard deviation of the number of edge points distributed in each gradient direction bin must be normalized to ensure its versatility for differently shaped regions. \(T_{g}\) is a threshold that limits the maximum standard deviation of the edge points distributed over each gradient direction bin. If the condition is satisfied, then the overall distribution of the edge points of the shape in the gradient direction bin is considered to be uniform. In the actual test, the values of the above threshold parameters are follows: \(T_{m}=32\), \(T_{n}=25\), \(T_{g}=0.035\). The proposed method can extract shapes with rich features and regular contours. For example, the poor shapes of types (a) to (b) in Figure 4 show a good exclusion effect. The reason is that the edge gradient direction of the shape (a) in Figure 4 is mainly concentrated in the horizontal direction, whereas the edge gradient direction of the shape in Figure 4b is mainly concentrated in the vertical direction, and it has a single gradient direction.