Photometric Stereo

Project Report

Guoliang Jin (login: aliang)

1.     Goal

This project implements a system to construct a height field from a series of images of a diffuse object under different point light sources. It calibrates the lighting directions, finds the best fit normal and albedo at each pixel, then finds a surface which best matches the solved normals.

2.       Steps

0).   Converting the given images from .tga from .png

It is possible to do this using Matlab with some extra libraries, but I did this using ¡°save as¡± in Photoshop. I handed in the result .png images.

1).   Calibration

The only calibration step we need to do is calibrating the lighting directions. Using the given images of a shiny chrome sphere in the same location as all the other objects, we can determine the normal at any given point on its surface, and compute the reflection direction for the brightest spot on the shiny chrome sphere surface.

2).   Computing the normal of each pixel in the image, generate normal map

In my implementation, I compute the normal for each channel as described on the project web page, but I only generate normal map for one channel as the results are similar among these three channels. As the number in the unit surface normal can be -1 to 1, so I add 1 to each number and then divide them by 2. The result looks better than without doing this.

3).   Solving for color albedo, generate albedo map

Computing the albedo for each channel as described on the project web page. I computed the normal for each channel independently in step 2, so I use the corresponding normals when I compute the albedo for each channel.

4).   Least square surface fitting

        I use the equation descried on the project web page to compute the surface which has the normals computed in step 2 (just use one channel). I first count the number of equations to make M smalled.

3.       How to run the program

To generate the result for a particular set (the following use buddha as example, you can replace buddha with the name of the set you want), type the following in Matlab:

numOfImg = 12;

chromeDir = 'psmImages\chrome';

chromePrefix = 'chrome.';

chromeFmt = 'png';

L = calibStereo(numOfImg, chromeDir, chromePrefix, chromeFmt);

 

inputDir = 'psmImages\buddha';

inputPrefix = 'buddha';

inputFmt = 'png';

myStereo(numOfImg, inputDir, inputPrefix, inputFmt, L);

 

then you will get three figures: normal, albedo and 3D, the normal and albedo images will also be stored at inputDir.

I also created a file called ¡°main.m¡±, which calls calibStereo once, and then calls myStereo six times with the corresponding parameters for each set of images.

4.       Result

          Buddha:

              RGB-encoded normals                                                                                                                               

              

              albedo map

         

              3D view 1                                                                                          

             

              3D view 2

         

          cat:

              RGB-encoded normals                                                                                                                               

         

              albedo map

         

              3D view 1                                                                                          

             

              3D view 2

         

          gray:

              RGB-encoded normals                                                                                                                               

          

              albedo map

         

              3D view

         

              3D view 2

         

                

          horse:

              RGB-encoded normals                                                                                                                               

         

              albedo map

         

              3D view

         

              3D view 2

         

          owl:

              RGB-encoded normals                                                                                                                               

         

              albedo map

         

              3D view

         

              3D view 2

                

          rock:

              RGB-encoded normals                                                                                                                                

         

              albedo map

         

              3D view

         

              3D view 2

                

               

5.       Discussion

1).   I just followed the description on the project web page, and everything works fine.

2).   One problem I got was when I did the step 4, I got a lot of NaN(not a number)s. As I am new to Matlab, so it took me some time to find the reason. Finally I found one vector N computed in step 2 was set to NaN, as the length of the vector is 0 and I divided the vector by the length to get a unit vector.

3).   The fourth step is time consuming. A bigger problem is that if the images grow big, then Matlab may complain do not have enough memory. In my implementation, I counted the number of equations to make the matrixes smaller. One can also write program in other programming language rather than Matlab to handle this.