# Bridge Displacements Monitoring Method Based on Pixel Sequence
## 2 The DoG Algorithm Applied for Edge Detection  
Data obtained through algorithmic processing of graphics can then be subjected to deeper signal processing by the computer. Common preprocessing methods include grayscale conversion and binarization, which translate the information of each pixel into a format understandable by computers. However, interference from some noisy pixels can affect the desired results. Therefore, during preprocessing, it is crucial to apply denoising techniques to the images to enhance their quality. Common denoising methods include median filtering, mean filtering, bilateral filtering, and Gaussian filtering. To mitigate Gaussian noise, the utilization of a Gaussian filter based on the noise distribution function is advisable. The expression for the Gaussian low-pass filter function in the image is as follows:  
\[G(x,y)=\frac{1}{\sqrt{2\pi\sigma}}exp\left(-\frac{x^{2}+y^{2}}{2\sigma^{2}}\right) \tag{1}\]  
where (x, y) represents the pixel coordinates of the Gaussian kernel. G(x, y) denotes the value of the two-dimensional Gaussian function at coordinates (x, y). During the processing stage, the Gaussian filter operates by smoothing the image, wherein the gray value of pixels is represented by the weighted average of neighboring pixels. Particularly at the image edges, where the gray value tends to increase, the weighting of surrounding pixels in the Gaussian filter is comparatively reduced. This preservation of edge details is essential during noise reduction processing. Due to this property, feature detection at a certain scale can be performed by subtracting two adjacent Gaussian scale-space images to achieve the desired outcome. This results in the DoG response image. \[ \begin{array}{lcl}g_{1}(x,y)=G_{\sigma_{1}}(x,y)&*&f(x,y)\\ g_{2}(x,y)=G_{\sigma_{2}}(x,y)&*&f(x,y)\end{array}  \tag{2}\]  
where g represents the blurred result of the image at a certain Gaussian scale, and f represents the value of a specific pixel or a pixel region in the input image. Subtracting the two images g1 and g2 yields the expression for the DoG (Difference of Gaussians) function:  
\[DoG\triangleq g_{1}-g_{2}=\frac{1}{\sqrt{2\pi}}\left(\frac{1}{\sigma_{1}}e^{ -\frac{x^{2}+y^{2}}{2\sigma_{1}^{2}}}-\frac{1}{\sigma_{2}}e^{-\frac{x^{2}+y^ {2}}{2\sigma_{2}^{2}}}\right)~{}*~{}f(x,y) \tag{3}\]The main purpose of applying differential processing to images is to enhance edges and details while suppressing noise. Through multi-scale analysis, features at different scales can be extracted. The precision of edge extraction is higher after performing the Gaussian difference operation, and it does not introduce large-scale noise. The main steps of edge detection include gradient calculation, calculation of gradient magnitude and direction, and non-maximum suppression. The main purpose of gradient calculation is to compute the gradient of the difference image to obtain the edge strength and direction. The specific calculation formulas are as follows:  
\[\
abla D(x,y)=\left(\frac{\partial D}{\partial x},\ \frac{\partial D}{\partial y}\right) \tag{4}\]  
where \(\
abla D(x,y)\) represents the image gradient using the Gaussian difference method; \(x,y\) represent the pixel directions in the horizontal and vertical axes, respectively. The formulas for calculating gradient magnitude and direction are as follows:  
\[M(x,y)=\sqrt{\left(\frac{\partial D}{\partial x}\right)^{2}+\left(\frac{ \partial D}{\partial y}\right)^{2}} \tag{5}\]  
\[\theta(x,y)=\arctan\frac{\frac{\partial D}{\partial y}}{\frac{\partial D}{ \partial x}}) \tag{6}\]  
where \(M(x,y)\) represents the gradient magnitude of the pixel, and \(\theta(x,y)\) represents the gradient direction of the pixel. Multiple convolutions with the DoG (Difference of Gaussians) function can be applied to an image, as depicted in Figure 1. This technique aids in amplifying the detection of relatively subtle structures, which might otherwise be overlooked or challenging to identify in subsequent processes.