Canon PowerShot G2 – RAW format info.

<Previous page Next Page>

Most digital cameras use a monochrome sensor with a Bayer filter matrix overlaid. Some argue (and I agree) that the term pixel is misleading in the context of these camera. A pixel in a color system is generally a color pixel. Each pixel on my monitor is RGB, a pixel from my scanner(s) are RGB. My G2 has 4 million photosites but only one million R and B and two million G. A 4 Mpix RGB file is created by filling in the missing values. This is usually done with a simple interpolation routine but better methods exist and I have explored a few on my own.

This is what the raw CCD data looks like. Each pixel is covered by a colored filter. The software which processes the image knows the filter geometry and estimates the actual pixel color by processing a group of pixels.

A close-up of the eye shows a regular pattern caused by the "Bayer matrix" filter over the CCD.


This is the offending pixel. It doesn't look much but it is annoying having to retouch the same pixel again and again. It looks much worse after it has been processed by the color estimation code and passed thru a sharpness filter. This image also ends some online speculation about whether RAW images have already been sharpened – obviously they are not – this is A GOOD THING!


And this what the CCD data looks like with the correct filter color in each cell. The image looks green because there are twice as many green cells as there are reds or blues. It looks dark because light has been removed by the filters. The color interpolation process will fix both these effects.


Now I've written a simple interpolation routine. I've left some stripes unprocessed for comparison. This a brain-dead routine - there is a bit of research going on into improved algorithms. I hope to try something better. This is still fairly raw data – there has been no white-balancing – black level subtraction, gamma correction, filtering or sharpening.


My code is based on some public domain code written my David Coffin. I have converted it to delphi and this has been a non-trivial task. David Keenan also helped me with a 5 minute tutorial on Huffman encoding.

NEXT>