# Tilt-Induced Error Compensation with Vision-Based Method for Polarization Navigation
## 2 Principle of Visual Horizontal Attitude Angle Measurement
### Horizon Extraction Method  
Following the segmentation of the image, distinct boundaries are present, which can be detected using gradient-based algorithms. The traditional Canny edge detection algorithm primarily relies on gradient information to determine edge locations and detect detailed and weak edges. However, when images exhibit considerable noise or are affected by illumination variations, false detections or missed edges may occur [31]. This paper proposes an adaptive bilateral filtering-based Canny operator to overcome this issue. The initial phase of Canny edge detection involves the application of adaptive bilateral filtering on the image. The bilateral filtering formula is  
\[f^{\prime}(x,y)=\frac{1}{W}\sum_{q\in s}f(q)\cdot\omega(p,q) \tag{12}\]  
where \(s\) represents the local neighborhood centered at pixel \(P\); \(f(q)\) denotes the pixel value at point \(q\); \(\omega(p,q)\) signifies the weight between \(p\) and \(q\); and \(W\) is the normalization coefficient for the weights. The formula for \(\omega(p,q)\) is as follows:  
\[\omega(p,q)=\omega_{s}(p,q)\cdot\omega_{r}(p,q)=\exp\biggl{(}-\frac{\parallel p -q\parallel^{2}}{2\sigma_{s}^{2}}\biggr{)}\cdot\exp\biggl{(}-\frac{\parallel f (p)-f(q)\parallel^{2}}{2\sigma_{r}^{2}}\biggr{)} \tag{13}\]  
where \(\omega_{s}(p,q)\) represents the spatial weight between pixels \(p\) and \(q\), where \(\sigma_{s}\) is the standard deviation of the spatial Gaussian kernel; \(\omega_{r}(p,q)\) denotes the pixel weight between pixels \(p\) and \(q\), where \(\sigma_{r}\) is the standard deviation of the pixel-value Gaussian kernel.  
The improved Canny operator effectively detects the edge of the image, mitigates interference from non-edge regions, identifies detailed edges, and effectively suppresses noise. The designed Canny operator can be expressed as  
\[E(x,y)=\left\{\begin{array}{l}-1,G(x,y)<T_{l}\\ 1,G(x,y)>T_{h}\\ 0,T_{l}<G(x,y)<T_{h}\end{array}\right. \tag{14}\]where \(E(x,y)\) is the final binary image; \(G(x,y)\) is the gradient of the image; \(T_{l}\) and \(T_{h}\) signify the low and high thresholds, respectively.  
Figure 4 presents a comparative analysis of the edge detection results using the basic and improved versions of the Canny algorithm. The result obtained using the basic Canny algorithm shows blurred edges, missed weak edges, and noticeable noise. In contrast, the improved Canny algorithm produces clearer and more continuous edges while significantly reducing noise. This comparison highlights the advantages of the improved algorithm in terms of edge clarity and noise suppression, validating the effectiveness of the proposed enhancement.  
After the edge detection of the image, the image containing the horizon edge is obtained. In order to obtain accurate horizon parameters, it is necessary to extract the line from the image after edge detection. The traditional Hough transform achieves line detection by mapping image edge points to parameter space; nevertheless, it requires traversing all edge points (totaling M), which leads to large computation and high storage costs. Therefore, the progressive probabilistic Hough transform is adopted in this paper to calculate a subset of the edge points (the number is m, and the number is satisfied \(m<M\)), thus significantly reducing operational complexity and storage requirements [32]. In addition, the method can directly detect the two endpoints of the line, enabling accurate line positioning without relying on post-processing.  
To evaluate the robustness and consistency of the proposed horizon line detection algorithm, Figure 5 presents the processing results for three representative image frames. These frames were selected to include variations in viewpoint and scene composition. As illustrated, the algorithm accurately identifies the horizon line in each case, demonstrating its stable performance across different inputs. This confirms the method's potential for reliable application in real-world UAV visual attitude estimation tasks.