GithubHelp home page GithubHelp logo

peterzs / depth-from-polarisation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from waps101/depth-from-polarisation

0.0 0.0 0.0 38.8 MB

Linear depth estimation from an uncalibrated, monocular polarisation image

License: Apache License 2.0

MATLAB 100.00%

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

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.