Analyzing a Shadow

June 06, 2011
Updated: June 07, 2011

I want to draw realistic shadows, but all techniques I have found look bad. So to learn more I have tried to analyze if a shadow can be simulated.

The challenging region of a shadow is its blurry edge, the penumbra. Knowing how it turns from dark to bright is essential for drawing. This could depend on many factors, e.g. the shape of the light casting the shadow, the color of the light, etc. So in order for the analysis to not get out of hand I will impose some restrictions. The only type of shadows I will analyse are shadows cast by the Sun. I will try to find out if how these shadows turn from dark to bright can be be described by a linear gradient, Gaussian blur, or as a shadow from a uniformly radiating disc.

The last alternative assumes that the Sun is a Lambertian radiator, i.e. the intensity of the light emitted is described by Lambert’s cosine law. However, the Sun is affected by limb darkening and is darker at the edges than the center. So it may turn out that Gaussian blur is a better model.

The Experiment

To know something, I need data. Assuming all shadows from the Sun has the same blurry edge, it will be sufficient to only analyze one shadow. And to make the analysis simpler, I took a photo of the edge of a straight shadow on a gray background.

Drawing of the experiment.

A drawing of how the photo was taken.

I took the photo with a Ricoh Caplio GX100 and exported it using Adobe Lightroom 3. This is a scaled version of the photo.

A shadow from the Sun.

A shadow that is easy to analyze.

Initial Analysis

The analysis is the same for each of the three color channels and the results are very similar. The following results are from the green sRGB channel.

All pixels in a column of the photo has approximately the same intensity. The column-wise histogram and the column-wise mean are useful to get an overview of the data.

Column-wise histogram of the shadow photo.

Column-wise histogram of the shadow photo.

Column-wise mean of the shadow photo.

Column-wise mean of the shadow photo.

Curve Fitting

I tried three ideas for functions that may estimate the shadow. A linear gradient, Gaussian blur, and a shadow from a Lambertian radiator. I used genetic programming to find parameters for each function so that it would fit the photo. The best Euclidean distance to the photo were 70.97 for the linear gradient, 70.01 for Gaussian blur, and 68.90 for the shadow of a Lambertian radiator. Here are their graphs.

Estimating the shadow with a linear gradient.

Estimating the shadow with Gaussian blur.

Estimating the shadow with a shadow of a Lambertian radiator.

top: Estimating the shadow with a linear gradient.
middle: Estimating the shadow with Gaussian bur.
bottom: Estimating the shadow with a shadow of a Lambertian radiator.
Each graph has the estimate painted in black and the column-wise mean painted in green.

Conclusion

The only way to evaluate which method is best is to paint the estimated shadows and to perform a visual inspection. This is how each model would estimate the shadow.

The estimated shadow.

Estimated shadow. From top to bottom: linear gradient, Gaussian blur, and shadow of a Lambertian radiator.

©2016 Mats Mattsson