Hope everyone is having a colorful wide-gamut 2025!
I did some experiments with the intention of using Rolf’s @cpixip xp24_full.dng
as reference to develop a processing path for the raw values TIFF in Resolve, and to that effect, the raw values of the DNG file were extracted into a TIFF without no other color information.
The script used to extract the TIFF was:
## Remix from @cpixip script to analyze DNG files.
import numpy as np
import rawpy
import tifffile
path = r'xp24_full.dng'
inputFile = input("Set raw file to analyse ['%s'] > "%path)
inputFile = inputFile or path
outputFile = inputFile+".tiff"
# opening the raw image file
rawfile = rawpy.imread(inputFile)
print ('Rawfile Pattern',rawfile.raw_pattern[0][0])
print ('Rawfile shape', rawfile.raw_image_visible.shape)
# get the raw bayer
bayer_raw = rawfile.raw_image_visible
bayer_raw_16 = bayer_raw.astype(np.uint16)
rgb_frame = np.zeros(( 1520,2028,3),dtype=np.uint16)
# quick-and-dirty debayer
if rawfile.raw_pattern[0][0]==2:
# this is for the HQ camera
red = bayer_raw_16[1::2, 1::2] # Red
green1 = bayer_raw_16[0::2, 1::2] # Gr/Green1
green2 = bayer_raw_16[1::2, 0::2] # Gb/Green2
blue = bayer_raw_16[0::2, 0::2] # Blue
elif rawfile.raw_pattern[0][0]==0:
# ... and this one for the Canon 70D, IXUS 110 IS, Canon EOS 1100D, Nikon D850
red = bayer_raw_16[0::2, 0::2] # Red
green1 = bayer_raw_16[0::2, 1::2] # Gr/Green1
green2 = bayer_raw_16[1::2, 0::2] # Gb/Green2
blue = bayer_raw_16[1::2, 1::2] # Blue
elif rawfile.raw_pattern[0][0]==1:
# ... and this one for the Sony
red = bayer_raw_16[0::2, 1::2] # red
green1 = bayer_raw_16[0::2, 0::2] # Gr/Green1
green2 = bayer_raw_16[1::2, 1::2] # Gb/Green2
blue = bayer_raw_16[1::2, 0::2]
elif rawfile.raw_pattern[0][0]==3: #HQ SRGGB12
red = bayer_raw_16[1::2, 0::2] # red
green1 = bayer_raw_16[0::2, 0::2] # Gr/Green1
green2 = bayer_raw_16[1::2, 1::2] # Gb/Green2
blue = bayer_raw_16[0::2, 1::2]
else:
print('Unknown filter array encountered!!')
rgb_frame[:,:,2] = (blue)<<4
rgb_frame[:,:,0] = (red)<<4
rgb_frame[:,:,1] = ((green1+green2))<<3
tifffile.imwrite(outputFile, rgb_frame, compression=None)
The starting point was the Resolve processing settings in this post. But after experimenting a bit instead of using the Davinci Wide Gamut
color space, the Blackmagic Design Wide Gamut Gen 4/5
appear to have slightly wider range, and I swapped all the nodes and color transformations that in the posting use wide gamut to Gen 4/5.
The TIFF, extracted from the DNG, has no color space information. The DNG in the posting is being developed to P3 D60
, and then the color transformation node goes from it to the wide gamut. In the case of the TIFF, there is no developer, only direct raw values. To that effect, the node sequence is first a Color Space Transform with input P3-D60, and output of Blackmagic Design Wide Gamut Gen 4/5
. The CST with these settings dimmed the chroma, and to compensate saturation was increased to 82.20 in the CST node. With more iterations/time to experiment, saturation may be reduced in this node.
Following the sequence comparison, with Vectorscope set to 2X.
DNG REFERENCE
TIFF from values extracted from DNG
Street TIFF
The node MATCH GAMMA takes its settings from the xp24_full TIFF Color Match node.
Note that the resulting TIFF pipeline (after the initial chroma increase) results in a more saturated picture than the DNG, and to that effect Saturation was reduced in the last node to match the DNG. Again, iterating between the Saturation setting on the first and last node may yield better results.
There is plenty of range in chroma -without clipping- on the last node.
To recap.
The well-known and challenging xp24_full.dng
is the matching reference.
The raw values of xp_24 were extracted, into a 16 bit TIFF.
The street scene is a test capture directly into 16-bit TIFF is a test image to validate results.
Processing pipe in Davinci Resolve was set for wide gamut, with a final/downstream conversion from wide gamut to rec709.
The DNG file is developed into P3-60 color space, and processed/color match. The reference.
The 16 bit TIFF is extracted from the DNG, brought into resolve color. Although the TIFF is not using any particular color space, the first node is a Color Space Transform to wide gamut, and good results were obtained setting P3-D60 as input. Nodes for OFFSET, GAIN/WB condition the raw values before a final node of COLOR MATCH/GAMMA is used for fine tuning. The color chart in the picture is used to adjust the TIFF final MATCH GAMMA node.
To process the street file, the settings (all nodes) from the x24 TIFF are applied to the street TIFF. The first and last nodes will be unchanged to preserve the match between DNG and TIFF obtained with xp24 set. The nodes for OFFSET and GAIN/WB will need to be adjusted to balance the RGB channel raw values before the MATCH GAMMA node does the final matching.
Note: the beak has a spot that is clipped, unlike the DNG which addresses this with the developer, the TIFF clipping is visible.