Getting wrong colors after applying WB and rgb_cam

Hi

I try to do my own image processing, I am using LibRaw only to extract the raw data and all kinds of info from the header. I do my own debayering and so on.

My problem is that after applying the WB from cam_mul and then the gamma curve (at 2.2) the image is sort of OK but washed out in DNGs and so and so (not very accurate and washed out) on different RAWs (from Canon and panasonic). If I multiply every pixel with the rgb_cam matrix, the image looks worse than if I don't do it. Also, multiplying with that matrix will sometimes make some dark colors to go negative, so I have to check for that as well (is this normal, or am I doing something wrong?)

Is there any magic step besides of what I am doing?

What I do is:
1. Load image
2. libraw_unpack(raw_struct);
3. libraw_raw2image(raw_struct);
4. Do my own debayering
5. Do white balance
6. Convert to sRGB with rgb_cam
7. Tone curve
8. Display the image on screen (I am using SDL2)

Anything else I should be doing to get some similar to JPG colors?

I am not doing any other adjustments (yet), nor do I trim the levels to avoid the pinkish hue in over-exposed areas.

Forums: 

Dear Sir:

Dear Sir:

libraw_raw2image does NOT subtracts black level from image[] array, most likely this is the source of the problem (image looks dull and with magenta cast, right?)

-- Alex Tutubalin @LibRaw LLC

Thanks!

That was it, thank you very much!
I changed my code to:
libraw_raw2image(raw_struct);
libraw_subtract_black(raw_struct);

And it works very nicely :) (well, still have to do other things now, but the results are much better).