# Research on Image Mosaic Method Based on Fracture Edge Contour of Bone Tag
## 2 Basic Method  
### Contour Edge Calculation  
The purpose of the image binarization processing [18] is to effectively extract the edge texture [19] information of the fracture surface when using the edge detection algorithm so as to prevent the interference of the non-edge texture information of the image. The image binarization processing needs to perform the difference calculation in the horizontal and vertical directions to highlight the edge information. The horizontal direction is recordedas the \(X\) direction, and the vertical direction is recorded as the \(Y\) direction. The \(X\) and \(Y\) direction operators are shown in Formula (1)  
\[X_{direction}=\begin{bmatrix}-1&0&1\\ -2&0&2\\ -1&0&1\end{bmatrix}\quad Y_{direction}=\begin{bmatrix}1&2&1\\ 0&0&0\\ -1&-2&-1\end{bmatrix} \tag{1}\]  
Traverse the image pixels, define a box filter with a size of \(3\times 3\), and calculate the filter difference in the \(X\) direction and the \(Y\) direction of the pixel, respectively. The calculation method is as follows:  
\[I_{X}=X_{direction}*I_{x,y}/4 \tag{2}\]  
\[I_{Y}=Y_{direction}*I_{x,y}/4 \tag{3}\]  
In which, \(x\) and \(y\) correspond to the width and height of the image pixel coordinate point position, the value range of \(x\) is \(x\in[3,I_{width}-2]\), and the value range of \(y\) is \(y\in[3,I_{height}-2]\). After obtaining \(I_{X}\) and \(I_{Y}\), calculate the edge difference of the entire image, the calculation formula is (4)  
\[I_{score}=(I_{X}{}^{2}+I_{Y}{}^{2})^{\frac{1}{2}} \tag{4}\]  
The image edge difference of \(I_{score}\) is inserted into the image, and the difference in the image is normalized to prevent the difference from exceeding the range of 0-1.  
The Canny operator has a balance between denoising and edge details of the image and can be an ideal edge detection operator. The principle of edge detection is to select an appropriate Gaussian function to smooth the pixels of the image row and column and filter the noise. At this time, the normalized image is \(I_{x,y}\), and the gradient magnitude and direction of each pixel are calculated. The differential operator adopts \([-1,0,1]\) and \([-1,0,1]^{T}\), and the pixel gradient is set to \([g_{x},g_{y}]^{T}\). The calculation formulas of the pixel gradient magnitude and direction are as follows:  
\[M(x,y)=\sqrt{g_{x}{}^{2}+g_{y}{}^{2}} \tag{5}\]  
\[\theta(x,y)=\arctan(g_{y}/g_{x}) \tag{6}\]  
Perform non-maximum suppression operation on the gradient image, eliminate the stray noise in the process of image edge detection, calculate the high and low thresholds of the gradient edge pixels, and process the image pixels after the maximum value suppression according to the high and low thresholds. The maximum value suppression pixel grayscale is set to 0, the pixel grayscale greater than the high threshold is set to 1, and the pixels between the high and low thresholds are recorded as weak edge pixels to ensure the distinction between image texture and non-texture information. For accurate edge results, weak edges need to be suppressed. Comparing each pixel \(I_{x,y}\) Gradient direction pixel values in the surrounding 8 neighborhoods, the magnitudes of both pixels in the gradient direction are less than \(I_{x,y}\). It is an edge pixel; otherwise, the edge pixel is filled, and its gradient value is set to 0.