Pi CAMERA BAYER FILTER SPECTRAL RESPONSE

GIT Repository for Files/Code

BACKGROUND AND MOTIVATION:

Optical filters and sensors are expensive, limiting their utilization in DIY projects. My goal with this project was to quantify the spectral response of the Bayer filter of the Pi camera (OV5647). The RGB filters and corresponding CMSOS sensors can then be leveraged for Raspberry PI projects. 

 

Color cameras work by placing a light sensor behind either a red, green or blue filter. The sensor (and driving circuitry) output a value corresponding to the level of light intensity registered. An image is recorded by using millions of these sensor-filter combinations. 

 

 
 

To fully utilize the filters, the spectral response has to be quantified. My goal was to physically measure the transmittance of the filters using a monochrometer. The simplified instrument setup is shown below. A full spectrum light source is directed at a diffraction grating, where the angle can be changed to differentially output monochromatic light. 

 

 
 

The lens of the Pi camera was removed and a 3D printed holder was made to hold the fiber bundle ferrule. 

I wanted to measure the spectral response of the filters from 400-665 nm. Every 5 nm a picture (JPEG with RAW) was taken of the monochromatic light. The RAW format records the unprocessed sensor data. The following animation shows the JPEG images at each monochromatic wavelength.

spectrium_GIF.gif

DATA EXTRACTION and RESULTS

The pixels illuminated by the fiber bundle need to be extracted from the larger image (Though not shown here, one could increase the accuracy of this analysis by re-collimating the light). The following figure shows the original image and the extracted image. Although the JPEG image was not used for the Bayer analysis, the pixel locations that were used within the RAW data correspond to the pixel location within the JPEG. 

 

The RAW data was processed following this example. For each picture, the RAW data was averaged and normalized. The normalized intensities were then plotted against wavelength. My code, the original and cropped images can be found on my GIT.

 

BLUE FILTER

GREEN FILTER

 
 

RED FILTER

 
 
 

COMPARISON

The figure on the left is the quantum efficiency of the filters provided by the manufacturer found on Koen Hufkens blog. The figure on the right is the normalized data of the three filters. 

 

POTENTIAL PROBLEMS

I used a rectangular to circular fiber bundle to couple the monochrometer output and Pi camera (in retrospect I should have coupled them directly). The fiber can potentially attenuate the light and offset results. The lower figure shows the wavelength versus intensity for the fiber bundle used. 

The Mercury-Xenon light source used does not output a constant intensity at every wavelength. The following figure illustrates the normalized output of the lamp (from Hamamatsu). In my original analysis of the RAW data I did take the spectral lines into consideration. The correction (dividing the normalized RAW data by the normalized lamp output) did not follow the anticipated trends and was ultimately removed. This may indicate that the monochrometer is slightly uncalibrated.