I tried to use the green CCD pixels to construct a B/W image. As it turned out, demosaicing artifacts are already problematic here, even without having to worry about colour. I tried a bilinear interpolation algorithm, which produced major "jaggies", aka "zipper artifacts". Clearly, a problem here is that half the pixels in the reconstructed picture coincide with CCD pixels, while the other half have to be estimated by looking at neighbouring CCD pixels. If you use bilinear interpolation, you reconstruct the missing CCD pixels by averaging the four neighbouring CCD pixels. Averaging however means loss of contrast, and these averaged pixels usually have intensities somewhere in-between neighbouring pixels: in other words, zipper artefacts.
We might say that, the problem here is that the distance between each destination pixel and each source pixels varies per pixel (that is, it either coincides perfectly or it has distance 1 from the nearest source pixels). The quality of these two different types of pixels is noticably different. From an information point of view, the accuracy of the information for the two kinds of pixels is different, and the inaccuracy of the inaccurate pixels shows with this simple interpolation algorithm. So, do we need a more advanced algorithm? Not necessarily! At this point, I came up with the idea of equalising the distance between source and destination for the different destination pixels. How? By shifting the destination grid 1/2 pixel to the right and bottom. Now, each destination pixel overlaps exactly two source pixels, and, by linear interpolation, each pixel may be determined by averaging these two pixels. Voila, gone zipper artifacts! This simple technique produces sharp images with only minor diagonal "jaggies", and which are nearly as good as those from the camera, and sometimes have even better detail resolving power. This is quite remarkable, as a *lot* of research and development has gone in demosaicing algorithms, and the Canon camera I used has some of the best algorithms.
Test images for green channel demosaicing algorithm
Figure 1: demosaicing
green with and without shifting the destination pixels.
The grey
squares are the locations of the destination pixels, the shade of grey
indicates the distance from the nearest source pixels (i.e. accuracy).
The 1/2 pixel grid shift has another advantage: the difference between red and blue CCD pixels and the different final image pixels is also equalised. In fact, each destination pixel overlaps with exactly one red and one blue CCD pixel. Using bilinear interpolation on the red and blue channel produced a nice colour image with acceptable artifacts (better than some cameras).
Below are some test images done with this algorithm. Note that the interpolated images were sharpened in the luminance channel, and otherwise unmodified.
Colour demosaicing comparison
More test images...
Image1
Image2
Image3
Boris van Schooten
boris@13thmonkey.org