Monday, February 04, 2008

Demosaicing (a.k.a De-bayering)

When shooting with a RAW single sensor camera like Arri D-20, Red One or SI-2K, the final output quality is impacted significantly by the demosaic algorithm, possibly as much as any compression applied. The demosaic algorithm is the process that converts the one value per pixel of a raw bayer sensor to the more useful three color primaries per pixel like RGB (see wikipedia article on demosaicing.) The weird thing about demosaicing, is there is no single correct way to do it, as all the algorithms must interpolate the missing values, one guess can be as good as another. Of course some look more natural than others, and that gets tricky (i.e. impossible) to mathematically prove -- there are some parallels to building a visually lossless compression. Originally CineForm hasn't really got heavily involved in choosing one demosaic algorithm, as there are now hundreds of different algorithms, all pretty much claiming some superiority over the rest. Instead we have offered a plug-in structure that allows third parties to add any demosaic filter they wish. Silicon Imaging did this and believe Weisscam looked into doing the same. But of course CineForm is judged only by the filters we offer as standard, as we saw when we demonstrated a standalone Red One file convertor (now on hold to meet agreement terms with Red.) Graeme Nattress of Red, skillfully skewered the faults in the default demosaic we were using in that beta product in a reduser.net post. Of the beauty of competitive development is we were able to address the issues the next day. All this brought my attention back to having a good range of demosacic filters for the user to select from, rather then each camera vendor offering their own.

The latest builds on all our 2K+ products, there are now twice the number of demosaic filters offered, allowing you to tweak you image look as you need. See the subtle effects of each demosaic in closup on this image :
Click each of the check boxes to see the image with the various demosaicing filters applied.


Bi-Linear
5x5 Enhanced
CF Advanced Smooth
CF Advanced Detail 1
CF Advanced Detail 2
CF Advanced Detail 3

When I find the time, I will shoot something that will really push the demosaic.

While I did this test images under Premiere Pro on Windows, we now have the same control of the demosaic filters on the Mac. For more information please see our new CineForm RAW on Mac tech note.

5 comments:

Anonymous said...

interesting... detail 3 looks nice.

David said...

All depends on the image, sometimes extacting that much sharpness is not great for all post workflows, so we default to CF Advanced Detail 1.

Anonymous said...

Of course this is not true.
Better way is if you have
sensor 4 x resolution that you want it's mean that if you wish to obtain real 2 k resolution your sensor must be of 4096 x 2304 single color pixels. That way there is no too much aritmetics than xR+2yG+zB where x,y,z can be both integer or (preferably ) floating poating coeficients.There are noo need of complex EXTRAPOLATE algorithms. Important is that one set of 4 pixels will be used no more than once for obtaining only one full color point in output image. All other things are named extrapolation and FTC will fine somebody that not announced that something is not real but extrapolated.(scanners have announce optical resolution and extrapolated resolution it's not the same like cameras but is important idea.)
As a proove: unexperienced in Digital cameras,but experienced in old fashion cinematography observed that even with the same lenses, bayern sensor image is not sharp as film with same resolution and whatever complicated debayern you use.

David said...

For practical real world images, a bayer sensor is able to resolve a little better than 75% of the theoretical maximum resolution for any given pixel count. I only say that as you post started with "Of course this is not true", I only had guess that you're a luddite when is comes to using bayer imagers -- I don't really know what you are saying is untrue. Whatever you think, bayer imaging and demosaicing is here to stay, we're just try to help.

Tuxedo said...

Hi david,

For me CF Advanced Smooth is much better.