How do I correct white balance?

I am using libraw to convert a NEF file to a bmp file.
The order I call the functions are as follows -

LibRaw RawProcessor;
libraw_data_t imgD=RawProcessor.imgdata;
imgD.params.user_flip = 3;

Now I have tried to write my bitmap in two ways -
1. processedImg->data[]
2. RawProcessor.copy_mem_image();

Neither have created me a .bmp file with the correct white balance. However, creating a ppm file using one of the samples produces a faithful reproduction. What am I doing wrong?

Sorry if this is a duplicate - My first post did not show up and stated unpublished.


use_camera_wb uses camera

use_camera_wb uses camera White Balance ('As Shot').

If you need to specify your own white balance, use user_mul[] coeffs

P.S. All user comment/posts are published only after approval due to heavy comment spam

-- Alex Tutubalin

It turned out to be a colour space issue.

I later discovered that my problem was due to colour space. I got more vibrant colors once I specified the color space to sRGB (My camera is set to sRGB) - This matched the colours reproduced from LightRoom / Photoshop.

And another thing was that my pointers were incorrect. imgD.params.use_camera_wb=1; was not finding it's way back into the LibRaw RawProcessor structure.

Thank you :-)


Bharath Bhushan Lohray