INFO 290T Assignment 6
Estimating lighting from an image has many applications in photo forensics, computer vision, and computer graphics. Consider the illuminated sphere shown below. If, as in this case, the light illuminating the sphere is distant and the sphere is a Lambertian (matte) surface, the appearance (I) of a point (X,Y,Z) on the sphere's surface that is not in shadow is equal to the dot product between the 3D surface normal (N) at (X,Y,Z) and the 3D direction to the light source (L).
You will write some Python code to estimate light direction (L) from an illuminated sphere. You can assume there is only one distant light source in the scene and there is no other illumination or ambient light.
Load the 3D
X-,
Y-, and
Z-coordinates of the sphere and the corresponding illumination
I. After loading the files you will have four 41 x 41 matrices corresponding to the illumination I and the 3D coordinates of the sphere. That is, for any u and v between 0 and 40, the illumination on the sphere's surface at (X(u,v),Y(u,v),Z(u,v)) is I(u,v).
Display this sphere using the
plot_surface method in Python. Set the color values so that the displayed sphere looks like the sphere shown below.
For each (X,Y,Z) on the sphere's surface, determine the surface normal N. The surface normal at any point on the sphere is a vector from the sphere origin to the point. Since the sphere is centered at the origin, this is a simple calculation. The surface normal should be specified as a unit vector.
Using least-squares, estimate the lighting (a 3-D vector). Your solution should create an over constrained system of linear equations in the surface normal and illumination at each point (X,Y,Z) on the sphere's surface that is not in shadow (i.e. intensity is greater than zero). Your solution for the light vector L is determined by solving this system of linear equations using least-squares.