# Use of Gradient-Based Shadow Detection for Estimating Environmental Illumination Distribution
## 2 Materials and Methods
### Verification of Local Feature-Based Matching  
We follow our local feature-based examination with a verification procedure, to more precisely estimate the environmental illumination. In this study, we employ a low threshold value in the local feature-based examination, to avoid missing the important illumination sources. We found that using this low threshold means that candidate shadows passed by the local feature examination overlap each other significantly. In this case, the shadow map created by the passed illumination source is contained in those of the other light sources. The relative brightness of the shadow regions illuminated by more light sources becomes darker. By using the intersection sets of the passed shadow regions and their difference sets, we can compute the relative extent to which the shadow areas are darkened, considering the inclusion relationships between the different illumination sources.  
In Equation (5), \(S_{n}\) represents the \(n\)-th candidate shadow region created by the \(n\)-th illumination source, and \(S_{nm}\) represents the intersection region of the \(n\)-th shadow and the \(m\)-th shadow.  
Figure 4: (a) Shadow boundary of the candidate illumination source; (b) matched points in search region of the third shadow boundary line segment; (c) shadow casting elements (corners and sides of the AR marker) and matched elements.  
represents the \(n\)-th shadow region, except for the areas that overlap with other shadows. \(S^{{}^{\prime}}_{n}\) is computed by subtracting \(M\) from \(S_{n}\); \(M\) is the unified region of the intersection of the candidate shadows. \(S^{{}^{\prime}}_{mn}\) represents the pure intersection region of the \(n\)-th shadow and the \(m\)-th shadow, excluding the overlapping regions with another shadow, and \(N\) is the total number of candidate shadows. \(M\) is calculated as follows:  
\[M=\underset{n=1}{\overset{N-1}{\cup}}\underset{m=n+1}{\overset{N}{\cup}}(S_{n} \cap S_{m}),\ S^{{}^{\prime}}_{nm}=S_{n}\cap S_{m}-\underset{n=1,\ k\
eq n,m}{ \overset{N}{\cup}}(S_{n}\cap S_{k}). \tag{5}\]  
In Figure 5, four shadow maps (\(S_{1}\) to \(S_{4}\), denoted as (c), (d), (e), and (f), respectively) are generated by the local feature-based matching, and the \(S_{4}\) region with the lowest matching score is contained in \(S_{2}\). Here, the subscripts of the shadow maps are numbered in descending order of their matching scores. Figure 5g shows the \(M\) region of the four shadow maps, and Figure 5h shows region \(S^{{}^{\prime}}_{4}\) (red) within region \(S^{{}^{\prime}}_{2}\) (yellow). We examine whether region \(S^{{}^{\prime}}_{4}\) becomes sufficiently darker than region \(S^{{}^{\prime}}_{2}\) in the input image. Figure 5a shows that there is little difference in brightness between regions \(S^{{}^{\prime}}_{4}\) and \(S^{{}^{\prime}}_{2}\) in Figure 5h (red and yellow, respectively). Since the fourth candidate illumination source with the lowest matching score does not render a shadow region sufficiently dark, the fourth illumination source is removed. Among the candidate shadows passed by the local feature examination, our verification procedure can precisely choose the candidate shadow sets that best represent the real shadows in the image. Previous methods have been unable to examine the case of the overlapping casted shadows in scenarios where there are lights with the same azimuth and different elevation angles in the hemisphere [18]. Our proposed verification procedures, however, enable the problem of overlapping casted shadows in the scene to be solved.  
Figure 5: (**a**) Input image; (**b–f**) candidate shadow regions (\(S_{1}\), \(S_{2}\), \(S_{3}\), and \(S_{4}\), respectively) passed by local feature-based matching; (**g**) the total intersection region, \(M\); and (**h**) region \(S^{{}^{\prime}}_{4}\) within region \(S^{{}^{\prime}}_{2}\).