Problem when emulating dcraw document mode

Hi everyone,

I'm currently using LibRaw to extract a completely raw image without any interpolation or processing, similar to dcraw's document mode (dcraw -D -4). I'm attempting to achieve this by setting the following parameters:

params.no_iterpolation = 1;
params.gamm[1] = 1;
params.output_bps = 16;
params.output_color = 0;
params.no_auto_scale = 1;
params.no_auto_bright = 1;
params.highlight = 1;
params.adjust_maximum_thr = 0;

(Note: I am using Java and accessing the LibRaw C API through JNA, so I'm setting these parameters manually.)

The output works as expected and I get a raw image. However, when I compare the result from LibRaw to that from dcraw, I notice a small discrepancy: the pixel values from LibRaw are consistently 1 less than those from dcraw. I only get identical results when I set params.user_cblack = {-1, -1, -1, -1}.

Does anyone know why this discrepancy occurs? Is there something specific in how dcraw handles black level compensation or another internal parameter that I'm missing in LibRaw?

Any insights would be greatly appreciated!

Forums: 

dcraw -D is 'totally RAW, no

dcraw -D is 'totally RAW, no scaling'

Just skip processing and use raw data from imgdata.rawdata.raw_image (or color3_image,color4_image).

samples/unprocessed_raw.cpp sample is probably what you're looking for.

-- Alex Tutubalin @LibRaw LLC

And specific followup: there

And specific followup: there is no document mode in LibRaw::dcraw_process (and dcraw_emu), if you want to get something close, then an exact match of values ​​is not guaranteed with parameters your specified or any other parameter values (in addition to the fact that the black level may differ in some cases)

-- Alex Tutubalin @LibRaw LLC

Thanks a lot

Thanks for your suggestions! I've decided to directly use the data in rawdata.raw_image. I've realized that the 1 discrepancy might just be a coincidence after testing different raw formats.