## 2 Traditional Canny Algorithm and Its Improvement
### Calculation of Gray Moments  
Gray moments are statistical quantities that describe the distribution of gray levels in an image and can be used to characterize the local features of an image. The first-order moments reflect the average gray value of the image, the second-order moments reflect the degree of gray fluctuation of the image, and the third-order moments reflect the degree  
Figure 1: Flowchart of the gray moment sub-pixel edge detection method. of skewness of the image's grayscale. The k-th order gray moment is defined as shown in Equation (3). In this paper, a \(7\times 7\) operator template is used, i.e., \(\mathrm{k}=7\). \[\mathrm{m}_{\mathrm{k}}=\sum_{\mathrm{x}=1}^{\mathrm{N}}\sum_{\mathrm{y}=1}^{ \mathrm{N}}\mathrm{I}(\mathrm{x},\mathrm{y})\cdot\mathrm{x}^{\mathrm{k}}\cdot \mathrm{y}^{\mathrm{k}} \tag{3}\]  
In the equation, \(\mathrm{I}(\mathrm{x},\mathrm{y})\) is the gray value of the image at point \((\mathrm{x},\mathrm{y})\) and \(\mathrm{N}\) is the size of the template. The diagram of the ideal edge model for the gray moments is shown in Figure 2. The normalized parameter model \(\mathrm{E}(\mathrm{x},\mathrm{y},\mathrm{\rho},\mathrm{\theta})\) is jointly determined by four parameters, such as gray values of \(\mathrm{h}_{1}\) and \(\mathrm{h}_{2}\), edge position \(\mathrm{\rho}\), and edge direction \(\mathrm{\theta}\). The representation is shown in Equation (4). \[\mathrm{E}(\mathrm{x},\mathrm{y},\mathrm{\rho},\mathrm{\theta})= \begin{cases} \mathrm{h}_{1},&x\cos\mathrm{\theta}+\mathrm{y}\cos\mathrm{\theta}\leq\mathrm{ \rho}\\ \mathrm{h}_{2},&x\cos\mathrm{\theta}+\mathrm{y}\cos\mathrm{\theta}>\mathrm{ \rho}\end{cases}  \tag{4}\]  
The proportion of pixel points with gray values of \(\mathrm{h}_{1}\) and \(\mathrm{h}_{2}\) to the total number of pixel points in the entire edge is set to \(\omega_{1}\) and \(\omega_{2}\), respectively, and \(\omega_{1}+\omega_{2}=1\). So, the first three orders of gray moments \(\mathrm{m}_{\mathrm{k}}\) can be expressed as Equation (5). \[\mathrm{m}_{\mathrm{k}}=\mathrm{h}_{1}^{\mathrm{k}}\omega_{1}+\mathrm{h}_{2}^ {\mathrm{k}}\omega_{2}\,\mathrm{k}=1,2,3 \tag{5}\]  
Therefore, finding the gray moments of the first three orders is finding the weighted sum of the gray values of each pixel point with the expression shown in Equation (6). It should provide a concise and precise description of the experimental results, their interpretation, as well as the experimental conclusions that can be drawn. \[\mathrm{m}_{\mathrm{k}}=\sum_{\mathrm{i}=1}^{\mathrm{N}}\omega_{1}\mathrm{G}_ {\mathrm{i}}^{\mathrm{k}}\,\mathrm{k}=1,2,3 \tag{6}\]  
In the equation, \(\mathrm{G}_{\mathrm{i}}\) is the gray value of the i-th pixel point in the unit circle; \(\mathrm{N}\) is the size of the template; and \(\omega_{1}\) is the weight value corresponding to the i-th pixel point. The collation can be obtained as \(\omega_{1}\), \(\omega_{2}\), \(\mathrm{h}_{1}\), and \(\mathrm{h}_{2}\), with the formula shown in Equation (7). \[ \begin{cases}\omega_{1}=\frac{1+\mathrm{s}\sqrt{1/(4+\mathrm{s}^{2})}}{2}\\ \omega_{2}=1-\omega_{1}\\ \mathrm{h}_{1}=\mathrm{m}_{1}-\sigma\sqrt{\frac{\omega_{2}}{\omega_{1}}}\\ \mathrm{h}_{2}=\mathrm{m}_{1}-\sigma\sqrt{\frac{\omega_{2}}{\omega_{2}}}\end{cases}  \tag{7}\]  
Figure 2: Diagram of the ideal edge model. In the equation, \(\sigma=\sqrt{\mathrm{m}_{2}-\mathrm{m}_{1}^{2}}\), \(\mathrm{s}=\frac{\mathrm{m}_{3}+2\mathrm{m}_{1}^{3}-3\mathrm{m}_{1}\cdot\mathrm{ m}_{2}}{\sigma^{3}}\). Therefore, the edge position \(\rho\) and edge direction \(\theta\) can be obtained, and the expressions are shown in Equations (8) and (9), which are, respectively, as follows:  
\[\rho=\cos\theta \tag{8}\]  
\[ \begin{cases}\sin\theta=\frac{\mathrm{y}_{0}}{\sqrt{\chi^{2}+\mathrm{y}_{0}^{ 2}}}\\ \cos\theta=\frac{\mathrm{y}_{0}}{\sqrt{\chi^{2}_{0}+\mathrm{y}_{0}^{2}}}\\ \end{cases}  \tag{9}\]  
In the equation, \(\mathrm{x}_{0}\), \(\mathrm{y}_{0}\) are the grayscale center of gravity coordinates of the unit circle.