Question about using output_params to render an sRGB image

I am using libraw to render a 16-bit sRGB image from a RAW file. I understand that I need to set certain fields of output_params to enable this correctly. My settings based on my understand is below:

rp.imgdata.params.use_camera_wb = 1; // Use As Shot White Balance
rp.imgdata.params.output_bps = 16; // 16-bit output
rp.imgdata.params.no_auto_bright = 1; // Do not contrast stretch the image
rp.imgdata.params.output_color = 1; // sRGB space
rp.imgdata.params.gamm[0] = 1/2.4; // power for sRGB
rp.imgdata.params.gamm[1] = 12.92; // toe slope for sRGB

I expected this to match the dcraw_emu call:
dcraw_emu -w -o 1 -g 2.4 12.92 -T -W -6

but when I compare my output with the resulting TIFF file, there is a mismatch. Are my params settings correct to render 16-bit sRGB image?

I am unclear what the -6 option does because it talks says "Write 16-bit linear instead of 8-bit with gamma". I do not understand what it means.



dcraw_emu uses same dcraw

dcraw_emu uses same dcraw_process() call, so with same parameters output should be the same.

-6 results in 16-bit output:
case '6':
OUT.output_bps = 16;

(looks like docs need to be corrected)

-- Alex Tutubalin @LibRaw LLC


Hi Alex,
Thanks for confirming the settings are the same and for updating the help. However, I am getting differences for a RAW file from LEAF. I am providing a link to the file below:

My workflow is
// Set the imgdata.params as described above
// Copy the rendered image

For a NEF file in my possession, it works fine.


Cloned your settings into mem

Cloned your settings into mem_image_sample.cpp:

OUT.use_camera_wb = 1; // Use As Shot White Balance
OUT.output_bps = 16; // 16-bit output
OUT.no_auto_bright = 1; // Do not contrast stretch the image
OUT.output_color = 1; // sRGB space
OUT.gamm[0] = 1/2.4; // power for sRGB
OUT.gamm[1] = 12.92; // toe slope for sRGB

compared with

./bin/dcraw_emu -w -o 1 -g 2.4 12.92  -W -6 ~/8/RAW_LEAF_APTUS_22.MOS

Results are the same:

 md5 ~/8/*ppm
MD5 (/home/lexa/8/RAW_LEAF_APTUS_22.MOS-memi.ppm) = 0b7caab6cdeaddc8d418f7e09c571ca8
MD5 (/home/lexa/8/RAW_LEAF_APTUS_22.MOS.ppm) = 0b7caab6cdeaddc8d418f7e09c571ca8

-- Alex Tutubalin @LibRaw LLC


I am using 0.19.6 version + I am on Windows. I will look into my code and confirm my implementation is correct. Would it be possible for you to send me the PPM files for me to compare?