Do libraw manipulate the colors when loading? possible histogram normalize?

I created a little program that loads our .NEF images into OpenCV Mat objects. I also tried to use the samples coming with the source for converting to tiff or ppm. All 3 gave the same results, that the image looks like its been normalized in some way.

The image can be seen at https://04o62a.dm1.livefilestore.com/y2p7TPrRkirmyRkqZWfcwKZCK0Htr9OwJMe...

The left is the photoshop opened nef. It looks like we would expect from how the wether was the day we was flying. But using libraw gives the image to right which looks like its been normalized?

We would like to be sure that the images look like when they was taken and can manipulate it in any way our self.

Forums: 

With default settings, LibRaw

With default settings, LibRaw makes these adjustments on processing (dcraw_process()), very similar to dcraw processing:
0) Black level subtracted
1) White balance applied
2) Camera color profile applied
3) Range adjusted to 1% of pixels set to saturation

All these adjustments can be turned off via imgdata.params.* tuning

-- Alex Tutubalin

Depending of what

Depending of what normalization you need, you may use
1) imgdata.params.no_auto_bright=1 to disable auto brighten
2) params.no_auto_scale=1 to disable data scaling to 65536/camera_data_maximum
3) or just use raw data as is from imgdata.rawdata.raw_image (for bayer data) without calls to LibRaw::dcraw_process()

-- Alex Tutubalin

I tried imgD.params.use

I tried imgD.params.use_camera_wb = 1; and imgD.params.no_auto_bright = 1; which seems to be close. But the image is a bit to dark then. and if using no auto scale, it becomes almost black.

I gave up on just using the raw data without processing because I could not figure out how to make opencv do the demosaic.

I cant figure out if I am

I cant figure out if I am doing something wrong, or if its even possible to get the same result as the output of the nikon viewnx converter tool.

I am happy to provide a raw file and a expected image converted with viewns, if its something really easy for someone good at libraw/dcraw to confirm or deconfirm that its possible.

To get the same result you

To get the same result you need to reproduce hidden exposure correction and tone curve from ViewNX.

I know nothing about ViewNX internals, so cannot recommend something meaningful (try LibRaw's exposure correction with highlights compression as in my StackExchange reply)

-- Alex Tutubalin