Building a Pinhole Camera

CS194-26 Proj 2 (Project Web Page) : Building a Pinhole Camera

Project Overview

In this project, my partner and I built a pinhole camera. As is stated in the project spec, "the pinhole camera (also called the "camera obscura") is essentially a dark box with a pinhole on one face, and a screen on the opposite face. Light reflecting off an object is directed through the pinhole to the screen, and an inverted image of the object forms on the screen". It basically uses simple optics allowing the light raws to go through a focused hole, and the rays are projected on the back of the shoe box. Group Members: Girish Balaji, Ram Kalidhindi (involved in procuring the camera, building the box, taking all the pictures, but dropped the class due to waitlist processing issues)

My approach

My approach to this project was to follow the directions on the project spec:

Results

How did the pinhole size affect the image output? Basically until between an open hole with no pinhole to a 3mm pinohole, the resolution continued to go up. However, every pinhole size reduction resulted in a significant decrease in brightness. The decrease in brightness made it very difficult to discern the details in these darker images. Because of this brightness reduction, the 5mm ended up being the most effective. It actually produced a higher resolution than the open hole with no pinhole cover.

Campanile

iPhone
Width: Open ~3x3cm square
Width: 5 mm
Width: 3 mm
Width: 1 mm

Soda

iPhone
Width: Open ~3x3cm square
Width: 5 mm
Width: 3 mm
Width: 1 mm

Doe

iPhone
Width: Open ~3x3cm square
Width: 5 mm
Width: 3 mm
Width: 1 mm

Sproul

iPhone
Width: Open ~3x3cm square
Width: 5 mm
Width: 3 mm
Width: 1 mm

Traffic

iPhone
Width: Open ~3x3cm square
Width: 5 mm
Width: 3 mm
Width: 1 mm

House

iPhone
Width: Open ~3x3cm square
Width: 5 mm
Width: 3 mm
Width: 1 mm

Which pinhole is the best?

The best image results were produced by the 5mm pinhole. Note, we believe that the theoretical ideal resolution may be around 3mm given our dimesions but the lack of light for the lower dimensions makes 5mm the clear winner

The best results: 5mm

Post processing includes taking the 5 mm outputs, cropping the image, equalizing the histogram intensity, denoising the output, and possibly increasing the brightness if necessary. We'll go in to details after displaying the results

House

The 5mm snapshot
Post processing

Soda

The 5mm snapshot
Post processing

Sproul

The 5mm snapshot
Post processing

Traffic

The 5mm snapshot
Post processing

Campanile

The 5mm snapshot
Post processing

Doe

The 5mm snapshot
Post processing

How'd I do it?

The first part of the solution is cropping. While most of the pinhole camera outputs were in the same cropping requirements, I did this manually because there were a few that were different. After cropping I flipped the image because the image projected in the back of the shoe box is upside down

Second step is histogram equalization. I would use the cropped area and use skimage to distribute the pixel intensity uniformly from 0 to 255. This is necessary because the images are generally dark and centered in the bottom side of the spectrum. Histogram equalization would make it possible to discern details that were previously not visible. Sometimes the brightness would be too low as it was often sunny outside so I increased the brightness of these images.

Final step: denoising and sharpening. For denoising I used some of the traditional techniques available. I was familiar with adaptive median filtering but I found other denoising algorithms on skimage: wavelet denoising and bilateral denoising that were far more effective. For the sharpening for the image, I applied a laplacian filter over the image, scaled it by a tuned parameter, and then added it to the original image. Below is an example of the effect of denoising. The details are not very apparent but it makes a larger difference at lower resolutions.

Denoising Effect

Pre denoising
Post denoising

Pinhole Camera Setup

Here are images on how our box was setup
Figure 1
Figure 2
Figure 3
Figure 4
Figure 5
Figure 6

Design Innovation

Notice in Figure 1 the holder we developed along the hole where the pinhole goes. This made it very easy to switch out pinholes!