Monday, February 5, 2018

Improving the colour bleeding into dark image areas

After having developed many images with FDC, I've gained more experience, on the practical side, of its strengths and weaknesses. The only pronounced weakness is the colour bleeding into black or very dark image areas. Mathematically speaking, it's not astonishing that this happens if one considers the filters that are used for obtaining the chroma values.

So I've recently been contemplating about ways to improve this...

What are 'good' chroma values?

When demosaicking a uniformly coloured image area at low iso, any algorithm is practically perfect. Problems arise in areas where pronounced and/or high frequency changes in luminance induce artefacts in chrominance. Then you get false colour artefacts. They are, typically, crazy high chroma values.

Areas of colour bleeding are also characterised by having chroma values that are much higher than they should ideally be.

So 'good' chroma values are basically chroma values that are as low as possible, without losing relevant image information.

This brought me to the idea to use also chroma values of the original Markesteijn algorithm. Why throw them away if you have them already?

So the idea is to use the chroma of either Markesteijn or of the frequency domain approach, depending on which of the two is less saturated.

So in other words, I tried using that chroma which has the lowest absolute value.

After saving the chroma of Markesteijn, this is as easy as two additional lines of code:

cbcr[0] = ((ABS(cbcr[0]) < ABS(cb)) ? cbcr[0] : cb);
cbcr[1] = ((ABS(cbcr[1]) < ABS(cr)) ? cbcr[1] : cr);

The results are rather pleasing. For lower iso images, this yields very clean and artefact-free images. For higher iso images, from around 1.600 upwards, the original FDC approach is still better because this hybrid approach introduces more chroma noise. 

This approach looks really promising, so I'll prepare a fork along these lines on my GitHub repository one of these days.

To be continued...