## 3 Improved Coal Ganguue Image Segmentation and Defogging Methods
### Dust Defogging Algorithm  
Dust can interfere with the model's ability to extract features from coal and gangue images, resulting in the trained network model being unable to accurately distinguish between coal and gangue. To mitigate this issue, prior to performing coal and gangue image segmentation, the collected dust images are processed using a dual dark channel fusion method combined with Gaussian-weighted dehazing techniques. This method estimates transmittance by combining dual dark channels and Gaussian weighting [30]. It uses superpixel filtering and median filtering windows to calculate two layers of dark channels, which are then pixel-wise combined. A Gaussian function is employed to optimize the dark channel regions, and the transmittance is calculated. The transmittance map is further refined using guided filtering, ultimately restoring the dehazed image. The superpixel filtering and median filtering formulas are as follows:  
\[I_{1}(x)=\min_{y\in\phi(x)}(\min_{c\in(r,g,b)}I^{c}(y)) \tag{1}\]  
\[I_{2}(x)=\max_{y\in\Omega(x)}(\min_{\Omega\in\{r,g,b\}}I^{c}(y)) \tag{2}\]  
In the equations, \(x\) represents the coordinates of each pixel in the image, \(I(x)\) represents the foggy image captured by optical equipment under foggy conditions, \(I_{1}(x)\) refers to the result of superpixel filtering, and \(I_{2}(x)\) refers to median filtering. \(\Phi(x)\) denotes a block with the same depth of field segmented using the superpixel algorithm, while \(\Omega(x)\)represents a 30 \(\times\) 30 square filtering window. The formula for two-layer dark channel fusion is expressed as follows:  
\[I_{S}(x)=\beta I_{1}(x)+(1-\beta)I_{2}(x) \tag{3}\]  
In the equation, \(I_{s}(x)\) denotes the fused dark channel image, and \(\beta\) is the adjustment factor, typically set to 0.3. However, the dark channel value of the distant scene tends to be smaller after fusion, which causes residual fog in the original image. To address this, a Gaussian weighting function is applied for optimization, as shown in the following equation:  
\[I_{g}(x)=\frac{1}{S(x)}[\lambda_{1}I_{S}(x)+G(x)\times I_{3}(x)] \tag{4}\]  
In the equation, \(I_{g}(x)\) is the dark channel after Gaussian optimization; \(I_{3}(x)\) represents the dark channel image filtered by a minimum value block; \(S(x)\) is the total weight; \(G(x)\) is the Gaussian weight. The calculation of \(G(x)\) and \(I_{3}(x)\) is as follows:  
\[G(x)=\lambda_{2}\times e^{\frac{(15-I_{2}(x))^{2}}{Z}} \tag{5}\]  
\[I_{3}(x)=\min_{y\in\Omega(x)}(\min_{c\in(r,g,b)}I^{c}(y)) \tag{6}\]  
In the formula, \(\Omega(x)\) represents the square filtering window; \(\lambda_{2}\) and \(Z\) are parameters that adjust the shape of the Gaussian function. The larger the \(\lambda_{2}\), the steeper the Gaussian curve, while the larger the Z, the flatter the Gaussian curve. Generally, when \(\lambda_{2}\) = 2 and \(Z\) = 0.6, image details are well-preserved, and the overall effect is optimal. Finally, combining Equation (7), the transmission rate is calculated. To further eliminate the texture effect, guided filtering ([PERSON] et al. 2013) [30] is applied to refine the transmission map. The refined transmission map is then substituted into Equation (8) to restore the haze-free image. \[t(x)=1-\omega\min_{y\in\Omega(x)}\left(\min_{c\in\{r,g,b\}}\frac{I_{g}}{A^{c}}\right) \tag{7}\]  
\[J(x)=\frac{I(x)-A}{\max(t(x),t_{0})}+A \tag{8}\]  
In the formula, \(t_{0}\) is a constant introduced to prevent the transmission rate from being too low, set at 0.1; \(\omega\) is the haze retention index, where a higher value leads to a more pronounced defogging effect but can make the image overly sharp, causing loss of detail. Conversely, a lower value results in a less effective defogging, but the image retains more detail and appears smoother and more natural. According to experimental analysis, when the dust concentration is below 30%, the optimal defogging effect is achieved with a haze retention index \(\omega\) of 0.7 and a guided filter radius of 70.