## 3 Materials and Methods
### Shadow Detection  
Before shadow compensation takes place, the shadow areas must be detected. Shadows generally have some typical spectral features such as low brightness, high hue, and high normalized blue component \(B^{\prime}\) defined in Equation (1), and low normalized green component \(G^{\prime}\) in Equation (2). These simple features cannot be combined well to detect all the shadows. Therefore, some complex signatures, such as \(Q\) defined in Equation (3), \(A\)[31] described in Equation (4) and the Morphological Shadow Index (MSI) [32; 33] define in Equation (5) are applied to identify the detect condition formula for cloud shadows and ground shadows, respectively. \(Q\) and \(A\) are designed by extending the signature difference between shadow and non-shadow based on \(B^{\prime}\), \(I\), and \(G^{\prime}\). MSI is developed based on the Differential Morphological Profiles (DMP) of black top-hat transformed data.  
\[B^{\prime}=B/(R+G+B) \tag{1}\]  
\[G^{\prime}=G/(R+G+B) \tag{2}\]  
\[Q=B^{\prime}-I \tag{3}\]  
\[A=\left\{\begin{array}{ll}2B^{\prime}-I-G^{\prime},~{}G^{\prime}\leq T_{G^{ \prime}}\\ 2B^{\prime}-I-2G^{\prime},~{}G^{\prime}>T_{G^{\prime}}\end{array}\right. \tag{4}\]  
\[MSI=\frac{\sum DMP_{\text{B-TH}}(d,s)}{D\cdot S} \tag{5}\]  
Figure 1: Flow chart of automatic shadow compensation.  
where \(R\), \(G\), and \(B\) are red, green, and blue components in RGB space, respectively. \(B^{\prime}\) and \(G^{\prime}\) are the normalized blue component and the normalized green component, respectively. \(I\) is the intensity component in HSI space. \(T_{G^{\prime}}\) is the Otsu threshold of \(G^{\prime}\). \(s\) and \(d\) indicate the length and direction of the linear structure element (SE). \(DMP_{\text{B-TH}}(d,s)\) is the value in DMP when using the SE(\(d\), \(s\)). \(D\) and \(S\) denote the numbers of directionality and scale of the profiles, respectively.  
Generally, the ground object shadow and cloud shadow have some similarity and difference in spectral features. For instance, the ground object shadows have larger MSI values, while the cloud shadows have smaller amounts. Then, combined with the automatic Otsu threshold strategy [34], the ground object shadow and the cloud shadow are detected using Equations (6) and (7), respectively.  
\[C_{\text{GOSD}}=\left\{(i,j)\right\}[(B^{\prime}(i,j)>T_{B^{\prime}}\&\&l(i,j) <T_{I})]\left[Q(i,j)>T_{Q}\&\&G^{\prime}(i,j)<T_{G^{\prime}})\left\|A(i,j)>T_{ A}\right\|MSI(i,j)>T_{MSI}\right\} \tag{6}\]  
\[C_{\text{CSD}}=\left\{(i,j)\big{|}I(i,j)<T_{I}\|G(i,j)<T_{G}\|MSI(i,j)<T_{MSI}\right\} \tag{7}\]  
where \(C_{\text{GOSD}}\) and \(C_{\text{CSD}}\) are the pixels set of ground object shadow and cloud shadow. \(G(i,j)\) represents the value of the green component in pixel \((i,j)\). \(I(i,j)\) represents the value of intensity component \(I\) in HSI space in pixel \((i,j)\). \(B^{\prime}\) (\(i,j)\) and \(G^{\prime}\) (\(i,j\)) represent the value of the nominalized blue and nominalized green component in pixel \((i,j)\), respectively. \(Q(i,j)\), \(A(i,j)\), and \(MSI(i,j)\) are the corresponding value of the complex features \(Q\), \(A\), and \(MSI\) in pixel \((i,j)\), respectively. \(T_{B^{\prime}}\), \(T_{I}\), \(T_{Q}\), \(T_{G^{\prime}}\), \(T_{A}\), \(T_{MSI}\), and \(T_{G}\), indicate the Otsu thresholds of \(B^{\prime}\), \(I\), \(Q\), \(G^{\prime}\), \(A\), \(MSI\), and \(G\) components, respectively.  
Lastly, some scattered and small shadow areas are removed, and some shadow holes are filled using mathematic morphological operators such as erasing, dilating, opening, and closing. Then the final shadow regions are more complete for use in further compensation.