Hi @LuisSanz,
so today I was sick at home so I had some time to play with thisā¦ hereās what I found.
I think the differences are not due to WB, but rather to the way dcraw and RT deal with clipped highlights. Here is a patch to your dcraw.c
that enables a further highlight mode -H 10
, which tries to emulate what RT does (when highlight reconstruction is turned off):
diff --git a/dcraw.c b/dcraw.c
index ca28559..f30793b 100644
--- a/dcraw.c
+++ b/dcraw.c
@@ -10206,6 +10206,29 @@ next:
else
ahd_interpolate();
}
+
+ if (!is_foveon && highlight == 10) {
+ float dmin, dmax, q;
+ unsigned i, c, size;
+ int val;
+
+ for (dmin=DBL_MAX, dmax=c=0; c < 4; c++) {
+ if (dmin > pre_mul[c])
+ dmin = pre_mul[c];
+ if (dmax < pre_mul[c])
+ dmax = pre_mul[c];
+ }
+ q = dmax / dmin;
+
+ size = iheight*iwidth;
+ for (i=0; i < size*4; i++) {
+ if (!(val = ((ushort *)image)[i])) continue;
+ val = ((float)val) * q;
+ ((ushort *)image)[i] = CLIP(val);
+ }
+ highlight = 0;
+ }
+
if (mix_green)
for (colors=3, i=0; i < height*width; i++)
image[i][1] = (image[i][1] + image[i][3]) >> 1;
Here are three crops of your test image above, developed respectively with:
dcraw -v -T -4 -H 0 -W -o 1 -a -q 4 -c DSC_0934.NEF
dcraw -v -T -4 -H 10 -W -o 1 -a -q 4 -c DSC_0934.NEF
-
rawtherapee-cli -Y -tz -s -c ~/Downloads/DSC_0934.NEF
(neutral profile, RCD demosaicing)
It seems to me that the dcraw image with -H 10
is very close to the RT one. What do you think? The difference between -H 0
and -H 10
is in the scaling of the raw values to normalize them to the range [0, 65535]. -H 0
is more aggressive in clipping before demosaicing, whereas -H 10
is more conservative before demosaicing, but then rescales the values later. This is closer to what RT does. As to why this has an impact on your algorithm, well, I have no idea but I hope this could be helpfulā¦