## 2 Methods
### Improved Sparse Haar-Like Features  
[PERSON] and [PERSON] proposed four Haar-like features [10]. Figure 1 shows the texture features of these four basic directions.  
[PERSON] et al. proposed an improved Haar-like feature [16], pointed out that the feature D proposed by [PERSON] was invalid, and divided the new Haar-like feature into edge features, linear features, and surround features, as shown in Figure 2, where white means 1 and black means \(-1\).  
Figure 1: Four Haar-like feature operators. (**a**) Two-rectangle feature where rectangular regions are horizontally adjacent; (**b**) Two-rectangle feature where rectangular regions are vertically adjacent; (**c**) Three-rectangle feature; (**d**) Four-rectangle feature.  
Figure 2: Improved Haar-like feature operators.  
As for the actual problem of engine cylinder head detection, the area to be detected can be located based on the relationship between a certain point of the circular edge and the eight directions around it, but the accuracy is insufficient, as shown in Figure 3, where the blue points indicate the location to be detected and the green represents the location that is actually detected.  
From the above, we can see that Haar-like features are not accurate enough, and are obviously influenced by the illumination. In order to improve the detection accuracy, a sparse Haar-like feature is proposed in this paper, as shown in Figure 4, where green stands for 1, black for \(-1\), and white for 0. In the figure, the first convolution kernel of edge feature and linear feature rotates \(90^{\circ}\), \(45^{\circ}\) and \(135^{\circ}\) to get the last three.  
Let the size of convolution kernel be \(n\times n\), the rotation angle be \(\theta\), \(\Omega_{b}\) denote the black region, \(\Omega_{g}\) denote the green region, \(p_{b}\) and \(p_{g}\) denote the pixel points of the black and green regions. Thus, the calculation formula of the convolution feature is as follows:  
\[F_{i,j}=\sum_{p_{b}}^{\Omega_{b}}s_{b}\cdot I_{(i,j)-p_{b}}+\sum_{p_{g}}^{ \Omega_{g}}s_{g}\cdot I_{(i,j)-p_{g}}, \tag{1}\]  
where \(s_{b}\) denotes the value of the black region in the convolution kernel, which is \(-1\); and \(s_{g}\) denotes the value of the green region in the convolutional kernel, which is \(1\). Lastly, \((i,j)-p_{g}\) represents the relative position of the convolutional kernel centered on the \((i,j)\) point of the image.  
Finally, the convolution features are normalized to ensure that each feature contributes the same to the overall matching.  
\[\left\{\begin{array}{c}m_{a}=\max(F)\\ m_{i}=\min(F)\\ \widetilde{F}=(F_{i,j}^{m}-m_{i})/(m_{a}-m_{i})\end{array}\right. \tag{2}\]  
Suppose we take two convolution kernels of size 8 and 26, as shown in Figure 5. The convolution kernels in some areas are so small that it is difficult to distinguish certain pixels from the surrounding  
Figure 4: Improved sparse Haar-like feature operators.  
Figure 3: The results of Haar-like feature matching. (**a**) Low brightness; (**b**) High brightness.  
pixels, which will cause inaccuracy. Larger convolution kernels can suggest more information in the region and improve the detection accuracy, but take a long time to calculate.  
Therefore, in order to obtain more regional information and improve the calculating speed, the image pyramid and operator pyramid, which is a convolution kernel pyramid, are used to widen the local area, as shown in Figure 6.