# Tilt-Induced Error Compensation with Vision-Based Method for Polarization Navigation
## 2 Principle of Visual Horizontal Attitude Angle Measurement
### HSV-Based Dynamic Thresholding Image Segmentation Method  
Following image dehazing, segmentation is performed on the processed images. Leveraging the inherent separation characteristics of hue and luminance in the HSV color space, which effectively distinguishes chromatic and brightness variations between sky and ground regions, we employ a dynamic HSV-based threshold segmentation method.  
The HSV color space comprises three orthogonal components: Hue (H), Saturation (S), and Value (V) [30]. The image is initially converted from RGB to HSV space; the color space model is shown in Figure 3.  
The conversion formula from RGB color space to HSV color space is  
\[V=\max(R,G,B) \tag{9}\]  
\[S=\left\{\begin{array}{ll}0,\ V=0\\ \frac{V-\min(R,G,B)}{V},\ V\
eq 0\end{array}\right. \tag{10}\]  
\[H=\left\{\begin{array}{ll}0^{\circ},\ V=\min\\ 60^{\circ}(\frac{G-B}{\min}+0),\ V=R\\ 60^{\circ}(\frac{P-B}{\frac{P}{\min}}+2),\ V=G\\ 60^{\circ}(\frac{P-B}{V-\min}+2),\ V=B\end{array}\right. \tag{11}\]  
where \(H\), \(S\), and \(V\) represent the numerical values of the same pixel in terms of hue, saturation, and value (brightness), respectively; max and min refer to the maximum and minimum values in the set \(\{R\), \(G\), \(B\}\); where \(R\), \(G\), and \(B\) correspond to the red, green, and blue components of that pixel.  
Target color regions are segmented by setting thresholds. Typically, due to the sky's prevailing blue color, a specific hue range for blue can be selected to isolate the sky region.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Metric** & **Hazy Input** & **Dark Channel** & **Retinex-Based** & **Proposed** \\  & **Image** & **Prior Dehazing** & **Enhancement** & \\ \hline Entropy & 6.4946 & 6.6792 & 6.9951 & 7.2518 \\ PBM & 0.0242 & 0.0375 & 0.0347 & 0.0543 \\ NRPBM & 568.7738 & 892.0183 & 893.1601 & 1509.7513 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Comparison of objective evaluation results of image defogging methods.  
Figure 3: Color space model. (**a**) RGB space model; (**b**) HSV space model.  
In this work, the hue range for the sky region was determined by analyzing the HSV histogram and identifying the distribution of target pixels. The threshold for the sky region was set to the hue range of [0.5, 0.7]. Depending on the screen's brightness conditions, the precision of brightness extraction can be further improved by adjusting the saturation (S) and value (V). For the S channel, a fixed threshold range of [0.3, 1] was used to extract regions with higher saturation, which helps focus on areas with more vivid colors, such as the sky, and eliminate regions with low color intensity or grayish areas.  
This paper introduces a dynamic threshold adjustment strategy specifically for the V channel to mitigate the problem of inadequate segmentation performance associated with fixed thresholds in the HSV color space. For the V channel, a sliding window (e.g., 15 \(\times\) 15 pixels) traverses the image. The median brightness of the region within each window is calculated as the baseline local threshold. The threshold sensitivity is increased if substantial brightness variations exist inside the window, whereas it diminishes in more uniform regions. Finally, bilateral filtering is applied to smooth the thresholds between neighboring windows, ensuring seamless transitions and avoiding abrupt segmentation boundaries. This approach ensures stable segmentation results across diverse illumination conditions.  
After threshold segmentation, a binary mask distinguishing the sky and ground regions is obtained. A morphological closing operation is applied to remove noise, fill holes, and smooth edges, ultimately yielding the dynamic threshold-based segmentation results in the HSV color space.