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.

Forums: 

Dear Sir:

Dear Sir:

LibRaw's main goal is to extract raw data and metadata from RAW files, we're focused on it.
Postprocessing code (demosaic, etc) is derived from Dave Coffin's dcraw.c and we do not have any plans to improve it in LibRaw. We consider this postprocessing code as 'demo', or as 'quick and far-from-perfect way to implement some processing in other software'.

So, if you want to do something special, e.g. floating point processing, or better negative values handling, or something else, LibRaw provides full access to unaltered pixel values decoded from RAW. Sure, you'll need to implement demosaic and other postprocessing in your software.

-- Alex Tutubalin @LibRaw LLC