Depth from Focus

From MMVLWiki

Table of contents

Depth from Focus

3D surface metrology

  • You need to grab the focus stack with your microscope and digital camera.
  • The results will be even better, if the illumination optics of the microscope can project a pattern.
  • Non-destructive measurement of surface profiles
  • With our experimental settings we observed (of course the result will depend on the quality of the microscope)
    • Vertical resolution \ge 0.2\ \mu m (depending on aperture-size, magnification, projection-pattern and the surface properties of the object).
    • Lateral resolution \ge 2\ \mu m (depends).
  • Open Source (you are free to improve the code yourself if you redistribute it).

In general one can say: The lower the depth of field, the higher the resolution of the reconstruction. With high magnification (assuming constant numerical aperture) the resolution of the reconstruction goes up. The trade-off is that the reconstruction will cover a smaller area. This can be overcome by lateral stitching (e.g. cogwheel below).

Demonstration

Here are some typical microscope images (Surfi-Sculpt refers to objects, which has been shaped using a power beam (https://www.twi.co.uk/j32k/unprotected/band_1/surfi-sculpt_index.html)).

First surfi-sculpt object, Leica DM LAM
Enlarge
First surfi-sculpt object, Leica DM LAM
Second surfi-sculpt object, Leica DM LAM
Enlarge
Second surfi-sculpt object, Leica DM LAM
Piece of Suevit (enamel like material from meteorite impact) from the Nördlinger Ries (https://en.wikipedia.org/wiki/Ries), Leica DM RXA
Enlarge
Piece of Suevit (enamel like material from meteorite impact) from the Nördlinger Ries (https://en.wikipedia.org/wiki/Ries), Leica DM RXA
Micro-camera image of a hair on top of a laser printout
Enlarge
Micro-camera image of a hair on top of a laser printout
Surface of 10-pence coin, Leica DM LAM
Enlarge
Surface of 10-pence coin, Leica DM LAM

Using a focus-stack one can compute images with extended depth of focus:

Extended depth of view for first object
Enlarge
Extended depth of view for first object
Extended depth of view for second object
Enlarge
Extended depth of view for second object
Extended depth of view for Suevit (fringes have been removed manually)
Enlarge
Extended depth of view for Suevit (fringes have been removed manually)
Extended depth of view for the hair
Enlarge
Extended depth of view for the hair
Extended depth-of-field image showing part of the 10-pence coin (compare with 1.39 MByte video of focus stack (https://vision.eng.shu.ac.uk/jan/coin.avi))
Enlarge
Extended depth-of-field image showing part of the 10-pence coin (compare with 1.39 MByte video of focus stack (https://vision.eng.shu.ac.uk/jan/coin.avi))

If the surface can be illuminated properly, one can even do a 3D-reconstruction of the surface:

3D reconstruction of first object (742kB video) (https://vision.eng.shu.ac.uk/jan/grid1.avi)
Enlarge
3D reconstruction of first object (742kB video) (https://vision.eng.shu.ac.uk/jan/grid1.avi)
3D reconstruction of second object (725kB video) (https://vision.eng.shu.ac.uk/jan/wheel1.avi)
Enlarge
3D reconstruction of second object (725kB video) (https://vision.eng.shu.ac.uk/jan/wheel1.avi)
3D reconstruction of suevit (1.4MB video) (https://vision.eng.shu.ac.uk/jan/suevit.mpg)
Enlarge
3D reconstruction of suevit (1.4MB video) (https://vision.eng.shu.ac.uk/jan/suevit.mpg)
3D reconstruction of hair (1.4MB video) (https://vision.eng.shu.ac.uk/jan/hair.mpg)
Enlarge
3D reconstruction of hair (1.4MB video) (https://vision.eng.shu.ac.uk/jan/hair.mpg)
3D reconstruction of 10-pence coin surface. The profile is amplified 5 times (1.0 MByte video) (https://vision.eng.shu.ac.uk/jan/coin3D.avi)
Enlarge
3D reconstruction of 10-pence coin surface. The profile is amplified 5 times (1.0 MByte video) (https://vision.eng.shu.ac.uk/jan/coin3D.avi)
Red-cyan anaglyph image of first object (2.0MB video) (https://vision.eng.shu.ac.uk/jan/grid.avi)
Enlarge
Red-cyan anaglyph image of first object (2.0MB video) (https://vision.eng.shu.ac.uk/jan/grid.avi)
Extended depth of field image for a piece of sugar (compare with 532 kByte video of focus stack (https://vision.eng.shu.ac.uk/jan/sugarstack.avi))
Enlarge
Extended depth of field image for a piece of sugar (compare with 532 kByte video of focus stack (https://vision.eng.shu.ac.uk/jan/sugarstack.avi))
Extended depth of field image of glass fibers (compare with 1.09 MByte video of focus stack (https://vision.eng.shu.ac.uk/jan/fiberdf10x.avi))
Enlarge
Extended depth of field image of glass fibers (compare with 1.09 MByte video of focus stack (https://vision.eng.shu.ac.uk/jan/fiberdf10x.avi))
Reconstruction of 0.6 mm cogwheel using multiple focus sets
Enlarge
Reconstruction of 0.6 mm cogwheel using multiple focus sets
Icing of a cake as seen under the microscope
Enlarge
Icing of a cake as seen under the microscope
Optical microscope image of tungsten tip
Enlarge
Optical microscope image of tungsten tip
Optical image of tungsten tip (high magnification)
Enlarge
Optical image of tungsten tip (high magnification)

As the idea for the algorithm was fixed already, it was possible to implement the algorithm as a command-line tool in less than 4 days, using existing Mimas-software (exspecially the operators for boost::multi_array (https://vision.eng.shu.ac.uk/jan/mimas/docs/arrayOperators.html)).

As this is a "quick hack", there's still lots of space for improvements.

Download

Old C++ Implementation

The software for estimating height-maps and images with extended depth-of-field is available for free (under the LGPL)! You first need to install version 2.0 of the Mimas Real-Time Computer Vision Library to be able to compile and run depthoffocus-0.1 (https://vision.eng.shu.ac.uk/jan/depthoffocus-0.1.tar.bz2) (652 kByte). The software also comes with sample files to generate photo-realistic 3D-reconstruction using POVRay (https://www.povray.org/)!

New Ruby Implementation

Image:New.gif I've ported the program to Ruby (https://www.ruby-lang.org/). The new implementation is based on the HornetsEye Ruby-extension. It also requires TrollOp (https://trollop.rubyforge.org/). You can copy-and-paste the source code from the depth from focus example (https://www.wedesoft.demon.co.uk/hornetseye-api/files/stack-txt.html) page. The source code also comes with the HornetsEye source package.

See Also

External Links

Bookmark and Share

Personal tools