/Photometric-Stereo

Photometric stereo is a technique to recover local surface orientations

Primary LanguageC++

Photometric-Stereo

Photometric stereo is a technique to recover local surface orientations

Assignment Generalization

Its mathmatical principle can be easily found on Internet. This assignment is going to use multiple images of an object captured under different directional illuminations and the same viewpoint to calibrate the illumination direction, estimate the surface normal direction at every pixel.

Calculating Process

  • Using class PFMAcess provided by Dr. Qin to read the data in form of PBM
  • Read 21 images and transfer their data to Mat format (function Readstring & function Transfer)
  • Recorded every pixel value and formed their RGB value as Intensity matrix (function Calpix)
  • Calculated light intensity of ever image through the brightest point on the Lambertian sphere and take its albedo as 1 (function CalLam)
  • Calculated the illumination direction of ever image through the brightest point of the right metal sphere and its radium (function CalBPoint & function CalCenter & function CalL)

L=2(N.R)N-R
Nx=BPx-Cx
Ny=BPy-Cy
Nz=sqrt(R^2-Nx^2-Ny^2)
[ Taken R as (0,0,1) ]

  • Calculated the albedo and the surface normal for every point on the object(function CalG)

G= invert ( tranverse(L)*L)*tranverse(L)*I
kd = ||G||
N = G/kd

Result

(RGB, albedo and re-rendered pictures are arranged from left to right)

apple

elephant

pear

How to use

  • Be sure to install OpenCV on your computer
  • main class is included in PRECal.h and PRECal.cpp
  • Run the main function in pp.cpp
  • Enter the number of images you use
  • Enter the object's name ('apple','elephant'or'pear)
  • Wait for the reslut
    If you still have questions, please feel free to contact me. kongosu325@outlook.com