# Use of Gradient-Based Shadow Detection for Estimating Environmental Illumination Distribution
## 2 Materials and Methods  
### Candidate Shadow Generation  
Using the ARToolkit module, we can compute viewpoint tracking and interactions between virtual objects. The real camera position, and its orientation relative to a square AR marker, are calculated in real time. A square of a known size is used as a base for the coordinates of the frame in which the virtual objects are generated [17].  
In this paper, the marker is located on the top surface of a cubic reference object with a length of 8 cm. The 3-D AR marker occludes the incoming light in the scene and the shadow of the marker is cast onto a planar surface, herein referred to as the shadow surface. The transformation matrix from the marker coordinate to the camera coordinate is then estimated. Once the real camera position is known, a virtual object with the same shape and size as the real 3-D AR marker can be laid exactly over the real marker [4]. The light sources are assumed to be point lights positioned on the hemisphere. The candidate shadow maps and their boundaries can be generated on the shadow surface, according to the relationship between the light source and the camera. We can then obtain the positions at which the vertices of the top plane of the 3-D AR marker are projected onto the shadow surface. The edges of the top plane and the vertical edges of the side plane also consist of the shadow boundary lines. The intersection point of two shadow boundary lines is referred to as a potential shadow junction. Figure 2a shows the geometric elements of 3-D markers such as the upper/lower corners, top/side plane, and shadow surface. Figure 2b shows the delineated shadow boundaries (blue colored) of every candidate light source with \(30^{\circ}\) intervals in the elevation and azimuth angle. Figure 2c shows three corners (cyan colored) of the top plane of the AR marker, consisting of the candidate shadow and the cast points (yellow colored) on the shadow surface, and Figure 2d shows the shadow boundary (white colored) that is cast by one of the candidate illumination sources.  
It is difficult to establish correspondences between the image shadow features and the shadow elements (the corners and the sides of the 3-D AR marker) cast by the candidate light source, especially in cases where there are multiple light sources in the scene. This means that it is difficult to accurately obtain the shadow boundary, because the gradient information of the image is non-salient and cluttered. Figure 3a,b show the results of Figure 2 obtained using the Canny edge detector with two double threshold intensity values of 10 and 20, and 20 and 40, respectively. Previous shadow detection methods based on the shadow edges have generally assumed that accurate edges are detected in the image [18]. However, it is difficult to determine the proper threshold values for detecting the shadow  
Figure 1: Block diagram of the proposed algorithm.  
edges. Figure 3c,d show the gradient direction distribution obtained using the Sobel operator (3 by 3 mask). Here, only points with gradient magnitudes higher than two threshold values (10 and 20 for Figure 3c,d, respectively) are represented. The gradient direction is coded to eight directions, which are marked by eight different colors (see inset in Figure 3d).