darktable icon indicating copy to clipboard operation
darktable copied to clipboard

raw over exposed indication broken

Open thecb1 opened this issue 3 years ago • 36 comments

Describe the bug/issue The raw over exposed indication with its default settings does not mark the whole areas that are over exposed but its edges only.

To Reproduce See sample zipped arw file. nosky.zip

Screenshot with default settings threshold_1_0

Expected behavior Screenshot with threshold 0.99 threshold_0_9

Which commit introduced the error I saw it with 4.0 release first.

Platform

  • darktable version : 4.0.0-1
  • OS : 5.15.53-2-lts
  • Linux - Distro : arch
  • Memory : 8G
  • Graphics card : GeForce GT 730
  • Graphics driver : nvidia-470xx-dkms 470.129.06-1
  • OpenCL installed : opencl-nvidia-470xx 470.129.06-1
  • OpenCL activated : yes
  • Xorg : xorg-server 21.1.3-7
  • Desktop : plasma

thecb1 avatar Jul 18 '22 11:07 thecb1

Indeed, looks strange !

TurboGit avatar Jul 18 '22 12:07 TurboGit

I think this just wrong white point setting so probably no bug. Arw files are notorious for that...

jenshannoschwalm avatar Jul 18 '22 14:07 jenshannoschwalm

Additional comment: The raw files include a 'white-point' defining the maximum processed value. That value is read from exif data by the rawspeed decoders.

If that value is wrong, clipped data are not calculated as clipped so the clipped visualizing is wrong. That's exactly what you see here, so for me not a bug in the mentioned part of the code. It might be reported as a rawspeed bug or as only some cameras / images are affected a sony firmware problem. (Sony raw are notorious for that, it also leads to problems handling highlights btw)

jenshannoschwalm avatar Jul 20 '22 05:07 jenshannoschwalm

@jenshannoschwalm Thank you very much for the explanation. Actually it looks like the value is not read from exif but is the same as the default value in the cameras.xml from rawspeed.

find . -type f -name "*.ARW" -exec exiftool -WhiteLevel {} \; | sort | uniq -c
2380 White Level                     : 15360 15360 15360

The white point in the cameras.xml/that dt uses is 16383.

thecb1 avatar Jul 20 '22 07:07 thecb1

That exactly is the problem.!

jenshannoschwalm avatar Jul 20 '22 08:07 jenshannoschwalm

So - why not "dig into this" deeper and try to fix it. I have not seen pr's by you so far but this might be a starting point to contribute to the dt project :-) And - it would help many Sony users :-)

jenshannoschwalm avatar Jul 20 '22 08:07 jenshannoschwalm

So - why not "dig into this" deeper and try to fix it. I have not seen pr's by you so far but this might be a starting point to contribute to the dt project :-) And - it would help many Sony users :-)

I am. I try to figure out how to make sure the proprietary values parsed by exiftools are reliable enough to fix it that way in rawspeed.

@TurboGit You want to close this issue? (Because you added it to the milestone)

thecb1 avatar Jul 20 '22 08:07 thecb1

A quick reminder, we will need to take care of old edits somehow. That might be a bit tricky as we have to make dt aware of other coeffs here. Don't know how to make sure about this but we will find a way :-) Good to see someone working on this nasty thing.

jenshannoschwalm avatar Jul 20 '22 08:07 jenshannoschwalm

isn't whitelevel saved in rawprepare iop params for old edits?

parafin avatar Jul 20 '22 08:07 parafin

I hoped that dt would keep the settings of the raw b/wp module and sets the value only on import or history reset.

I skimmed over some issues from rawspeed and some code from other raw software. I think one needs to inspect a variety of raw files shot with different settings first. It smells like there are more factors than just ISO that influence the black and white points. E.g. as I mentioned in chat the other day, the A6400 likes to switch between 12 and 14 bit with different settings.

thecb1 avatar Jul 20 '22 08:07 thecb1

isn't whitelevel saved in rawprepare iop params for old edits?

Yes, you're right @parafin those are saved so we can safely change the value which will be used for new edits or if the history stack is reset.

TurboGit avatar Jul 20 '22 09:07 TurboGit

@TurboGit You want to close this issue? (Because you added it to the milestone)

Not sure to understand. I did add a milestone to have a target release for the fix. The issue will be closed only if we decide to take no action or if a fix is merged.

TurboGit avatar Jul 20 '22 09:07 TurboGit

@TurboGit @aurelienpierre and others. There is definitely a problem in current whitepoint setting, don't yet understand the issue exactly. So far we thought it was some sony stuff, here is a link to a canon image issue, same probem.

https://discuss.pixls.us/t/highlight-reconstruction-darktable-vs-rawtherapee/31790/7

I think this is an issue we have to fix asap.

can this be related to moving away from adobe coeffs?

EDIT: a first lookup shows colordata.cpp to contain a maximum value (whitepoint?) If we use that data, are we sure that rawprepare takes parameters in the same way as rawprepare uses them?

jenshannoschwalm avatar Jul 22 '22 20:07 jenshannoschwalm

Maybe change the issue title to get more attention?

jenshannoschwalm avatar Jul 22 '22 21:07 jenshannoschwalm

I further checked the mentioned cr2 file and also here the whitepoint is simply wrong. dt uses 15831 instead of what exiftool says

Normal White Level              : 11767
Specular White Level            : 12279

jenshannoschwalm avatar Jul 23 '22 06:07 jenshannoschwalm

The uploaded Sony raw contains two different White Level tags :

exiftool -H -G -a nosky.ARW | grep "White Level"
[EXIF]          0xc61d White Level                     : 16383
[MakerNotes]    0x787f White Level                     : 15360 15360 15360

Using the value from the MakerNotes in raw black/white point the indicator is working as expected. The same applies for the image in the thread @jenshannoschwalm mentioned :

exiftool -H -G -a 2014-05-30_19-47-01.cr2 | grep "White Level"
[MakerNotes]    0x02cf Normal White Level              : 11767
[MakerNotes]    0x02d0 Specular White Level            : 12279

Edit: I checked a complete folder (129 images) of ARW files from my old Sony SLT-A77. For all files dt used a white point of 16596 in raw black/white point while the value reported by exiftool is 15360. These files do not contain the [EXIF] tag, only the [MakerNotes] as shown above.

pehar1 avatar Jul 23 '22 06:07 pehar1

I tested a NEF image with dt 3.4 & 4.0 :

3.4: image

4.0: image

An indeed I don't have the exact same area displayed. So something has changed, maybe the move to rawspeed adobe coefs indeed.

EDIT:

4.0 with https://github.com/darktable-org/darktable/commit/60a65ac17ab45f195ed55862d4e69029e58983ec reverted:

image

(close to what we had in 3.4).

TurboGit avatar Jul 23 '22 07:07 TurboGit

The uploaded Sony raw contains two different White Level tags :

exiftool -H -G -a nosky.ARW | grep "White Level"
[EXIF]          0xc61d White Level                     : 16383
[MakerNotes]    0x787f White Level                     : 15360 15360 15360

Indeed. I compared a bunch of ARWs from my 6400. In 14bit mode 0xC61D is always 16383 (14bit int max), but in 12bit mode it's always 16380. Anyway, the Sony specific value in 0x787F is always 15360, even in high ISO modes. For the moment 15360 looks more correct than maxint. But I don't know how to proof this is the absolute correct white level to use.

Other findings: The black level switches from 512 to 2048 (all four) on ISO 64000 and above. Though "64000" is read from exif data and not the actual camera setting.

thecb1 avatar Jul 23 '22 07:07 thecb1

can this be related to moving away from adobe coeffs?

I'm not sure about this, my understanding is that would have also made a visible change on images. This has happened for some cameras (very limited number as far as I know) where there was discrepancies between the old coefs recorded in dt and the ones now used from rawprepare.

TurboGit avatar Jul 23 '22 07:07 TurboGit

Just some random thoughts from a non-coder...

I learned, the wrong whitepoint is set already since long time, just the effect is more clearly visible recently.

Can that be due to so "door openings" during libraw integration?

This thought wouldn't finally solve the correct pick up, but maybe helps something for analysis or comprehensive understanding?

AxelG-DE avatar Jul 23 '22 09:07 AxelG-DE

Can that be due to so "door openings" during libraw integration?

I don't think so since the API for this library is only called when no rawspeed support is found for a specific image format. You can check which module to load the RAW has been used by looking at the flags value in image information module. The last character is r for rawspeed and l for libraw (tooltip tell you about this).

TurboGit avatar Jul 23 '22 09:07 TurboGit

I'm not sure about this, my understanding is that would have also made a visible change on images.

I checked a bit further. My current understanding is like:

  1. The raw overexposed visualizing is absolutely correct as we have it now if we define overexposure as values above a certain value and that value is defined as threshold*whitepoint
  2. Old and new code take the whitepoint from rawspeed / libraw (from my tests these settings did not change at all) but the values seem to be constant (dng work fine here btw as they have defined exif data)
  3. For some images there are makernotes that would give correct values but we can't/don't currently read them. This results in incorrect whitepoints. All dsc.processed_maximum[k] = 1.0f are set this way.

Questions for me now:

  1. Could we check for existing range-of-data and normalize in rawprepare?
  2. Any chance to read more makernotes

jenshannoschwalm avatar Jul 23 '22 09:07 jenshannoschwalm

donno it is interesting: @TurboGit mentioned above, similar trend for NEF files.

I have checked NEF and ORF files on my PC and diff. cameras, I do not find any white level at all in them... strange

AxelG-DE avatar Jul 23 '22 09:07 AxelG-DE

I have checked NEF and ORF files on my PC and diff. cameras, I do not find any white level at all in them... strange

They use the constant values we also use which seem to be correct.

jenshannoschwalm avatar Jul 23 '22 10:07 jenshannoschwalm

Could it be due to this commit 60a65ac17ab45f195ed55862d4e69029e58983ec

TurboGit avatar Jul 23 '22 10:07 TurboGit

I have checked NEF and ORF files on my PC and diff. cameras, I do not find any white level at all in them... strange

They use the constant values we also use which seem to be correct.

but see Pascal's result above with NEF...

@thecb1 helped me to find this where I understand from, it is hardcoded (but who says, it remains untouched?)

AxelG-DE avatar Jul 23 '22 10:07 AxelG-DE

but see Pascal's result above with NEF...

That's what @jandren changed and i think that's correct. The visualizing is not the issue for me ...

jenshannoschwalm avatar Jul 23 '22 10:07 jenshannoschwalm

That's what @jandren changed and i think that's correct.

I'm not saying that it is not correct, just that it may explain the difference we see between 3.8 & 4.0.

TurboGit avatar Jul 23 '22 10:07 TurboGit

4.0 with https://github.com/darktable-org/darktable/commit/60a65ac17ab45f195ed55862d4e69029e58983ec reverted:

image

(close to what we had in 3.4).

TurboGit avatar Jul 23 '22 10:07 TurboGit

And the OP picture with https://github.com/darktable-org/darktable/commit/60a65ac17ab45f195ed55862d4e69029e58983ec reverted:

image

TurboGit avatar Jul 23 '22 10:07 TurboGit