This project implements Photometric Stereo via Expectation Maximization by Tai-Pang Wu and Chi-Keung Tang.
First we need to quantize all the possible directions. We use the vertices of the upper half of a subdivided icosphere at level 4. We use code from here.
Then we interpolate the images with light directions as the quantized ones. The original light directions each has a nearest quantized direction and some quantized directions are nearest directions of multiple original directions. For this quantized direction, the set V
contains these multiple original directions. Now we can interpolate the images by the formula.
Find denominator image by the following steps.
- Calculate the intensity percentile of each position over all the images.
- For each image, count the number of pixel with percentile > 70%,
k_L
. - For each image, calculate the average percentile of the pixels with percentile > 70%,
r
. And calculate the percetile of eachr
. - Discard all the images that the percentile of
r
> 90%. - Choose the image with the largest
k_L
from the remaining images.
Divide each image by the denominator image to get ratio images. For each position in each ratio image, we have this equation.
In total we have N-1
equations for each pixel. Solve the system by SVD.
Again we quantize the possible directions by the upper half of a icosphere at level 5. And we use them as labels and want to assign these finite labels to each pixel so that the energy is minimized.
We can get the surface plot by the following steps.
- Vertically flip the normal map.
- Convert normal to gradient
(-N(1)/N(3), -N(2)/N(3))
. - Convert gradient to slant and tilt by this tool.
- Convert slant and tilt to depth map.
- Plot depth map by Matlab
surf
function.
The initial normal map, refined normal map, refined surface and refined surface with texture.