Add new comment

Conserving negative pixel values after demosaicing

I'm wondering if there's any way to conserve the negative pixel values after demosaicing which are quite important on noisy pictures because not clipping those values is the best way to avoid having purple haze (when the image has black parts and the negative values are clipped then the noise averages out to something positive instead of zero, which creates a haze, and typical white balance makes it purple), mostly when applying a blurring, denoising or downscaling algorithm to the image. Ideally LibRAW would be able to make images in floating point format or at least signed integer, but this doesn't seem to be the case.

I understand how to read the actual raw bayered pixel values, which typically have a value offset so after subtracting that offset I may have my precious negative pixels, but if I go that route it seems I'm on my own for the rest of the processing, which means doing my demosaicing, white balancing (that one's easy), chromatic aberration correction and colour correction (which I don't know how to do but my colours look very faded/desaturated when I try to do it all myself from the bayered data), so it seems like for me to reimplement the wheel just to conserve negative values is going to be difficult.

Is there any other way? Are there perhaps plans to output to anything other than 16-bit unsigned? It would be perfect if we could get unclipped demoisaiced pixels in 32-bit linear floating point with the green maximum normalised to 1.0 (by "green" I mean whatever's the channel with the lowest white balance compensation gain, usually green) (then it's up to us to see what we want to do about red and blue pixels above 1.0 after white balancing), processing images in linear 32-bit floats is the way to go for general image processing these days anyway.