I have a .CR2 image taken by a Canon 80D camera. I'm using LibRaw to convert it to a .TIF. The .TIF which is created is darker than the original .CR2 file (when viewed using Canon's Digital Photo Professional or Irfan View)
I read the contents of the .CR2 file to a buffer, then pass the buffer to this method to convert and save to .TIF:
void raw2image_concise(const char* data, size_t length) { LibRaw rawProcessor; rawProcessor.imgdata.params.output_tiff = 1; // tiff rawProcessor.imgdata.params.output_bps = 16; // bits per sample: 8 or 16 only, other values are invalid rawProcessor.imgdata.params.no_auto_bright = 1; // when disabled, image is too bright, when enabled, too dark? rawProcessor.imgdata.params.use_auto_wb = 0; rawProcessor.imgdata.params.use_camera_wb = 1; rawProcessor.imgdata.params.use_camera_matrix = 1; rawProcessor.imgdata.params.user_flip = 0; // no rotation rawProcessor.imgdata.params.user_qual = 3; // AHD interpolation rawProcessor.open_buffer((void*)data, length); rawProcessor.unpack(); rawProcessor.dcraw_process(); rawProcessor.dcraw_ppm_tiff_writer("test.tif"); }
I'd like to know if there's a way I can use LibRaw that won't result in a darker or brighter image.
I've also tried converting the .CR2 to .TIF using Digital Photo Professional and Irfan View, and the files these create don't lose any brightness.
I can provide the source .CR2, the .Tif that LibRaw creates, and the .Tif files created by Digital Photo Professional and Irfan View if that will help.
If you use no_auto_bright=1,
If you use no_auto_bright=1, than any brightening will be disabled, resulting in dark image if your shot is not exposed normally.
With auto_bright, LibRaw will put 1% of pixels (with default options) to saturation.
Today cameras gray point is usually at 12-10-even 7-8% of maximum (so, up to 4 stops from saturation). Raw converters (DPP, ACR, etc) usually use custom tone curves to compress highlights and get gray point back to 18% (so 0.7-1.5EV gray point move is usual)
-- Alex Tutubalin @LibRaw LLC
Using no_auto_bright=0 made
Using no_auto_bright=0 made the resulting image brighter than how the CR2 looks.
The histogram of the image changes. It's generally the same shape, but shifted. What parameters of libraw can i modify to try to keep the histogram in the same place? would modifying the tone curves that libraw uses acheive this?
What do you men by "not exposed normally"? I used 1/10 second exposure time, fNumber 5.6, ISO 160.
-shawn
You may disable automatic
You may disable automatic brightening and use manual exposure shift (exp_correc, exp_shift, exp_preser parameters). The exact amount of shift will differ on different cameras/different ISO values (see, for example, this article: https://photographylife.com/adobes-silent-exposure-compensation )
'not exposed normally' means that graypoint value is below 18% by some amount.
-- Alex Tutubalin @LibRaw LLC