A complete lensless imaging tutorial - hardware, software and algorithms

Eric Bezzam
5 min readFeb 10, 2022

In this post, we go through all the steps to build and use a lensless camera, specifically a modification of the DiffuserCam [1] proposed by Prof. Waller’s group at UC Berkeley that we call “LenslessPiCam”. This tutorial is useful for educators, hobbyists, and researchers interested in exploring lensless imaging with off-the-shelf, cheap components (about $80 for a Raspberry Pi, SD card, and the HQ sensor). With respect to the original DiffuserCam tutorial, we incorporate the newer HQ sensor, provide scripts for remotely interacting with the camera, provide more efficient reconstruction implementations, and make available tooling for quantifying performance. We also suggest exercises that could be interesting extensions for students.

(Left) raw measurement; (middle) LenslessPiCam with tape instead of a lens; (right) reconstruction, zoomed in. Images by author.

This post serves as a “global” overview, linking to other posts that describe all the steps towards building LenslessPiCam and obtaining results like the ones in the image above. All the code for this tutorial can be found at this GitHub repository.

If you are simply interested in lensless imaging reconstruction algorithms (and not building the camera), you can skip focus on Step 4 (“Evaluating the reconstructions”) / this article.

Feel free to send an email to eric[dot]bezzam[at]epfl[dot]ch if you have any questions / difficulties.

Why lensless imaging?

Conventional (top) vs. lensless (bottom) imaging. Image by author, inspired by Fig 4. of this paper [2].

Lenses are a key component of conventional cameras as they efficiently focus light onto an image plane. However, given a digital sensor the lens can be replaced with a different encoding element and a computational algorithm (see image above).

There are a couple of benefits of lensless cameras:

  • Thin / flexible form factor, as a potentially thick lens and tube configuration can be replaced by a thin mask (of arbitrary shape) closely placed to the sensor.
  • 3-D imaging and computational refocusing, as we obtain an unfocused image from a lensless camera.

For an overview of lensless cameras, their benefits, and shortcoming, we refer to this overview paper [3].

Finally, lensless imaging is a really neat, hands-on example of inverse problems and recovery. Great for educational purposes, as we have done for our Masters signal processing course at EPFL.

1) Setting up the Raspberry Pi and HQ sensor

HQ camera connected to a Raspberry Pi. Image by author.

As LenslessPiCam involves a Raspberry Pi (RPi), we need to first setup up the RPi. In this tutorial, we describe how to install the Raspberry Pi OS and connect the RPi to a WiFi network, all without the need of an external display.

In this tutorial, we describe how to setup SSH’ing without a password. This is necessary for the remote capture and display scripts we provide in the GitHub repository.

This tutorial describes how to setup the camera and how to focus a lens (sold separately) for the HQ camera. Focusing the lens is optional as we will be doing lensless imaging 😉

2) Building LenslessPiCam

Constructing the lensless camera with tape. Image by author.

With the RPi and sensor setup, we can proceed to building LenslessPiCam! This tutorial explains how to do just that with the HQ sensor, cardboard, electric tape and doubled sided tape. We really recommend using this type of tape (doubled-sided tape as the lens replacement and electric tape for cropping / holding things together) as we found it gave the best results.

While assembling LenslessPiCam, it will be useful to have a point source to help with creating the aperture (i.e. cropping). In this tutorial, we describe how to build one from an Arduino, a white LED, common electric components, and a cardboard box. A point source will also be needed to perform imaging.

3) Performing imaging

Performing point spread function (PSF) measurements. Image by author.

Now the fun part! Taking pictures 📷

This tutorial describes how to take measurements with LenslessPiCam, using scripts from the GitHub repository.

In this tutorial, we describe in more detail how to digitally reconstruct an image from the raw measurements. We also suggest some extension / exercises that can be done. If you are an instructor and would like the solutions, you can request access here or send an email to eric[dot]bezzam[at]epfl[dot]ch.

4) Evaluating the reconstructions

Example reconstructions. Image by author.

In the repository, we provide a script to remotely display pictures on an external monitor. This can be useful for creating a small dataset to evaluate different reconstruction techniques.

In this tutorial, we present different metrics that can be used for evaluating reconstructions, and present a dataset that can be used for evaluating different reconstruction strategies.

Summary

And that’s it! We hope you find the tutorial interesting, and that it helps you learn about and implement different aspects of lensless imaging.

Feel free to email us or leave comments for any questions / suggestions that you may have.

References

[1] C. Biscarrat, S. Parthasarathy, G. Kuo and N. Antipa. Build your own DiffuserCam: Tutorial, (2018).

[2] V. Boominathan , J. K. Adams, J. T. Robinson and A. Veeraraghavan, PhlatCam: designed phase-mask based thin lensless camera. (2020), IEEE Transactions on Pattern Analysis and Machine Intelligence.

[3] V. Boominathan, J.T. Robinson, L. Waller and A. Veeraraghavan, Recent advances in lensless imaging (2022), Optica.

--

--

Eric Bezzam

PhD student at EPFL. Previously at Snips/Sonos, DSP Concepts, Fraunhofer IDMT, and Jacobs University. Most of past work in audio and now breaking into optics!