Git Product home page Git Product logo

depth-from-polarisation's Introduction

Linear depth estimation from an uncalibrated, monocular polarisation image

This is a Matlab implementation of our ECCV 2016 paper "Linear depth estimation from an uncalibrated, monocular polarisation image". It also includes an implementation of polarimetric image decomposition (linear and nonlinear optimisation), two comparison shape-from-polarisation methods, a simple least squares surface integration method (which supports a foreground mask) and a basic method for pixel-wise specular labelling.

Note: I am in the process of cleaning up the code and adding to the repository. I will update the list of what has been uploaded as I go along. Content included so far:

  1. Comparison methods
  2. Least squares integrator
  3. Polarimetric image decomposition
  4. Diffuse polarisation model (degree of polarisation to zenith angle)
  5. Light source estimation
  6. Height from polarisation

Still to add:

  1. Specular model, specular labelling
  2. Boundary prior (computing boundary azimuth and weight)
  3. Sample datasets
  4. Code for generating synthetic datasets and evaluating

I will add documentation and demo scripts as I upload the code.

Polarimetric image decomposition

The first thing you need to do is convert your captured image into a 3-channel polarisation image. The function that does this is PolarisationImage.m. Inputs are:

  1. images - 3D array containing captured images of size rows by cols by nimages
  2. angles - vector of length nimages containing polariser angles (I use a coordinate system where the polariser angle is measured from the upward vertical axis, increasing in a clockwise direction if viewed looking into the camera lens)
  3. (optional) mask - binary foreground mask of size rows by cols
  4. (optional) method - either 'linear' or 'nonlinear', default: linear

It returns rho (degree of polarisation), phi (phase angle) and Iun (unpolarised intensity).

Sample call:

[ rho,phi,Iun ] = PolarisationImages( images,angles,mask,'linear' );
figure; imagesc(rho); colorbar
figure; imagesc(phi); colorbar
figure; imshow(Iun)

Convert degree of polarisation to zenith angle

For the time being, I only include the diffuse polarisation model. So to convert the degree of polarisation (rho) to a zenith angle, you simply do:

theta = rho_diffuse(rho,n);

where n is the index of refraction (we use n=1.5 in the paper).

Light source estimation

If you do not know your light source direction (or if you know it, but don't know the light source intensity/uniform albedo) then the next thing you need to do is estimate it. This is done using the findLight function. It can estimate point source or spherical harmonic order 1 or 2 lighting. A basic call for point source lighting where you don't know the direction would be:

[ l,T,B ] = findLight( theta,phi,diffuse,mask,3 );

Alternatively, if you know the direction is [1 0 1] but need to scale to account for unknown intensity/albedo, then do:

l = [1 0 1]'./norm([1 0 1]);
[ l,T,B ] = findLight( theta,phi,diffuse,mask,3,l );

For other options and spherical harmonic lighting, see the documentation.

Computing depth

Finally, we are ready to compute depth. Again, this is the most basic call assuming only diffuse pixels:

[ height ] = HfPol( theta,diffuse,phi,l,mask );

To display the height map, you can do, for example:

figure; surf(height'); axis equal

depth-from-polarisation's People

Contributors

waps101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

depth-from-polarisation's Issues

The results of running the Demo are different from the original paper

Hi Prof. Smith,
Thank you so much for open-sourcing this excellent work, I recently ran your demo and noticed a gap between the results and the results in your paper:

PaperImg MyResult

Here is the detailed code I ran

load sampleData.mat
[ rho_est,phi_est,Iun_est ] = PolarisationImage( images,angles,mask,'linear' );
n = 1.5;

theta_est= rho_diffuse(rho_est,n);
theta_est_combined=theta_est;
theta_s = rho_spec(rho_est(spec),n);
theta_est_combined(spec)=theta_s;
phi_est_combined = phi_est;
phi_est_combined(spec)=mod(phi_est(spec)+pi/2,pi);

% Estimate light source direction from diffuse pixels (note that you might
s = [2 0 7]';
[ s,T,B ] = findLight( theta_est,phi_est,Iun_est,mask&~spec,3,s );

% Compute boundary prior azimuth angles and weight
[ azi,Bdist ] = boundaryPrior( mask );

% Run linear height from polarisation
[ height ] = HfPol( theta_est_combined,min(1,Iun_est),phi_est_combined,s,mask,false,spec );

% Visualise
figure;
surf(height,'EdgeColor','none','FaceColor',[0 0 1],'FaceLighting','gouraud','AmbientStrength',0,'DiffuseStrength',1); axis equal; light

Can you help me, thanks a lot

Error in height calculation

Dear Prof. Smith,

thank you for sharing your code and for the advances in polarimetric computer vision.
I am currently working on my bachelor thesis, comparing your work against a multiview polarization method.
Unfortunately, I have an issue with your height estimation.
The result of your sample data and of my own data is always a linar increasing height with the x value.
The actual depth of the object is not recovered.
Until now, I haven't been able to fix this issue. I would really appreciate it, if you or someone from your team could help me, on why that might happen.

depthmap of the sample data:
height_smith_croped

depth from polarisation

Dear prof. William A. P. Smith @waps101
Thank you for sharing the codes. I have a question about it: I saw the results of surface normals in your amazing paper. How can we estimate surface normals from these codes?

Light source direction and code questions

Dear Professor Smith:
Recently, I am reading your academic paper <Linear depth estimation from an uncalibrated, monocular polarisation image>. My research direction is polarization 3D imaging. I hope to further study by reproducing the experimental results of your paper. During my further study, I encountered two questions:
1. The light source direction s=[2 0 7]' in the paper, there is no standard explanation for this representation, I hope you can guide.
2. In the implementation code of this paper, there is a data set of spec in the sample data, and the extraction code of this data set does not know whether it can be shared.
I would be very honored to have your guidance. Thank you for taking the time to read the letter。
Good luck!

How to visualize normal vectors

In the Hfpol function, the height information is returned directly, but I want to know, in this function, how the normal vector is generated, and then how to convert the normal vector to the depth information, can you tell me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.