This project attempts to determine the direction of light on a face from a single picture. Two approaches were taken for this project: detection through Principal Component Analysis and Gradient Direction Histogram comparison.
Principal Component Analysis was performed on a set of six faces under five different lighting angles. The chosen angles were front, left side, right side, top, and back. This data set can be viewed here. All faces were labeled with key points by hand and morphed to the mean face before PCA was performed. The analysis was able to determine that the five most important components were the different directions. Additional components started differentiating between facial features.
These components were saved for use later. Next, the average of the faces in each of the five different lighting conditions was taken.
These averages were projected into the PCA space and their coordinates were saved. To detect the direction of light, the test face is morphed to the mean face of the PCA set, projected into the PCA space, and the closest point of the five angles to the projected coordinate was determined to be the primary light direction.
An alternate approach was also investigated. This approach also takes a test image that has been warped to the mean face, but instead of projecting it into the PCA space, a histogram of the gradient diection is computed for it. The direction is only added to the histogram is its magnitude is greater than a threshold value. The magnitudes are normalized to the [0.0, 1.0] range before thresholding. The histogram uses bins in the range from -180 to 180 separated by 30. Similar histograms are also computed for the average faces for each of the lighting angles. All histograms are normazlied, then the test image histogram is compared to the average histograms using the Chi Square distance metric and the light angle with the smallest distance is determined to be the primary light direction.
Test photos were drawn from google searches and one was from my portfolio. Values in parentheses are distance measures returned by the algorithm. Smaller is better.
PCA
Ranking: front (155), right (164), top (174), left (201), back (205)
Histogram Distance
Ranking: top (0.676), back (0.691), front (0.867), right (0.986), left (1)
The light in this image is primarily from the right, however there is a lot of spill onto the center part of the face, which tilts the PCA analysis towards front light.