Issue : PWP clips highlights of linear DNG file

Moderator: jsachs

pierrelabreche
Posts: 638
Joined: January 29th, 2019, 11:47 pm
What is the make/model of your primary camera?: Nikon Z8

Issue : PWP clips highlights of linear DNG file

Post by pierrelabreche »

Scenario:


For example, use the file https://raw.pixls.us/getfile.php/6616/n ... 0(3:2).NEF
Convert the NEF file to DNG using Adobe DNG converter ( command-line interface, using parameters "-c -linear" )

Problem
PWP8 severely clips the highlights, unlike other editors

See screenshots below

PWP 8
2025-03-26 PWP clipped highlights.jpg
2025-03-26 PWP clipped highlights.jpg (60.57 KiB) Viewed 2190 times
DxO Photolab 8
2025-03-26 PL8 highlights.jpg
2025-03-26 PL8 highlights.jpg (46.97 KiB) Viewed 2190 times
Luminar Neo
2025-03-26 Luminar Neo highlights v1.jpg
2025-03-26 Luminar Neo highlights v1.jpg (87.42 KiB) Viewed 2190 times
Johannes
Posts: 1
Joined: February 24th, 2025, 12:17 pm

Re: Issue : PWP clips highlights of linear DNG file

Post by Johannes »

Hello Pierre,

I have downloaded the file and changed the extension to .NEF.
Fastrawviewer shows blown highlights (only the red channel is not clipped):
Screenshot 2025-03-26 192900 v1.jpg
Screenshot 2025-03-26 192900 v1.jpg (83.41 KiB) Viewed 2188 times
So I think the other editors create some data in the overexposed area.

Best regards Johannes
pierrelabreche
Posts: 638
Joined: January 29th, 2019, 11:47 pm
What is the make/model of your primary camera?: Nikon Z8

Re: Issue : PWP clips highlights of linear DNG file

Post by pierrelabreche »

Hello Johannes,

I went back to the NEF file (not the dng-converted file).
Blown highlights are detected after development. Exposure compensation plays a big role in this.

As shot, it has blown highlights, as detected by Photolab 8:
2025-03-26 PL8 with blown highlights151047.jpg
2025-03-26 PL8 with blown highlights151047.jpg (37.28 KiB) Viewed 2179 times
By reducing exposure somewhat, the highlights are moved to the left ( see histogram)
2025-03-26 PL8 with some blown highlights.jpg
2025-03-26 PL8 with some blown highlights.jpg (35.57 KiB) Viewed 2179 times
It can be processed without blown highlights by reducing exposure up to 0.90 stops in Photolab 8 :
2025-03-26 PL8 without blown highlights.jpg
2025-03-26 PL8 without blown highlights.jpg (33.56 KiB) Viewed 2179 times
Best regards
pierrelabreche
Posts: 638
Joined: January 29th, 2019, 11:47 pm
What is the make/model of your primary camera?: Nikon Z8

Re: Issue : PWP clips highlights of linear DNG file

Post by pierrelabreche »

Files sent separately via WeTransfer
jsachs
Posts: 4588
Joined: January 22nd, 2009, 11:03 pm

Re: Issue : PWP clips highlights of linear DNG file

Post by jsachs »

DNG files are processed by the third party software LibRaw which is based on something called dcraw. This is one of the reasons I generally recommend using a commercial raw converter as they handle highlight recovery better. In any case it is not something I have any control over.
Jonathan Sachs
Digital Light & Color
pierrelabreche
Posts: 638
Joined: January 29th, 2019, 11:47 pm
What is the make/model of your primary camera?: Nikon Z8

Re: Issue : PWP clips highlights of linear DNG file

Post by pierrelabreche »

When Linear DNG is used, I would expect that no other editor is required since demosaicking is already performed. In this case, demosaicking is performed by Adobe Camera Raw. It would be nice if PWP could directly input DNG files without clipping the highlights.

I asked Microsoft Copilot about libraw :
LibRaw provides several options to manage how raw data is processed, which might help address the issue of highlight clipping. Specifically, you can explore the structure libraw_output_params_t, which includes parameters for managing post-processing. One key parameter is highlight, which allows you to control how highlights are handled during processing. Setting this parameter to a value like 0 (no clipping) or 1 (clip to white) might help you avoid clipping.
Additionally, you can look into the gamma settings or other raw decoding options in the libraw_pack_unpack_params_t structure to fine-tune the output.
The documentation of the API is here : https://www.libraw.org/docs/API-datastruct-eng.html

Could you enable user-control of highlight and gamma ?

I noticed other parameters such as
float auto_bright_thr;
dcraw keys: none
Portion of clipped pixels when auto brightness increase is used. Default value is 0.01 (1%) for dcraw compatibility. Recommended value for modern low-noise multimegapixel cameras depends on shooting style. Values in 0.001-0.00003 range looks reasonable.
jsachs
Posts: 4588
Joined: January 22nd, 2009, 11:03 pm

Re: Issue : PWP clips highlights of linear DNG file

Post by jsachs »

Been there done that.
Jonathan Sachs
Digital Light & Color
pierrelabreche
Posts: 638
Joined: January 29th, 2019, 11:47 pm
What is the make/model of your primary camera?: Nikon Z8

Re: Issue : PWP clips highlights of linear DNG file

Post by pierrelabreche »

Could you enable user-control of highlight and gamma ? .... Been there done that.
Im not sure of what your answer means.

One more observation: Dark table, which is also built on RawLib, does not clip the highlights when processing the same DNG file.
jsachs
Posts: 4588
Joined: January 22nd, 2009, 11:03 pm

Re: Issue : PWP clips highlights of linear DNG file

Post by jsachs »

I have played with the highlight parameter and any setting other than the one I am using produces weird results.
Jonathan Sachs
Digital Light & Color
pierrelabreche
Posts: 638
Joined: January 29th, 2019, 11:47 pm
What is the make/model of your primary camera?: Nikon Z8

Re: Issue : PWP clips highlights of linear DNG file

Post by pierrelabreche »

I asked Google Gemini about the handling of raw files by darktable.
darktable uses the RawSpeed library to read raw files, including linear DNGs. RawSpeed is an open-source library originally developed by Klaus Post and now maintained as part of the darktable project.

Here's how darktable potentially handles the aspects you mentioned regarding reading linear DNG raw files and managing highlight clipping:

1. Reading Linear DNG Raw Files with RawSpeed:

darktable relies on RawSpeed to decode the raw data from linear DNG files. RawSpeed supports a large number of raw file formats from various camera manufacturers, including the DNG format.
RawSpeed provides the unmodified raw data, possibly scaled to 16 bits or normalized to 0->1 floating-point data.
It also provides the CFA (Color Filter Array) layout for known cameras and automatically calculates the black level for cameras with this information.
2. Highlight Clipping Management (related to LibRaw):

Although darktable uses RawSpeed for reading raw files, it's helpful to understand how the concepts mentioned regarding LibRaw might translate in the context of darktable:

libraw_output_params_t and the highlight parameter: RawSpeed, like LibRaw, must handle highlight clipping during demosaicing and initial processing of the raw data. While darktable doesn't directly expose the libraw_output_params_t structure, it offers several modules and options to manage highlights:

The "highlight reconstruction" module offers different methods to recover details in overexposed areas. These methods include "clip highlights", "reconstruct in LCh", and "reconstruct color". The "clip highlights" option would correspond to behavior similar to setting the highlight parameter to 1 in LibRaw (clip to white). The other methods attempt to reconstruct color and brightness information in clipped areas using neighboring unclipped pixels.
The "filmic rgb" module (or the older "base curve" module) also has a significant impact on highlight management by applying a tone curve that can compress the dynamic range and reduce clipping. The "filmic rgb" module has a dedicated "reconstruct" section for managing highlight clipping.
The "exposure" module allows adjusting the overall exposure of the image, which can help bring highlights back into a non-clipped range.
The "overexposure indicator" module allows visualizing areas of the image that are clipped in different color channels, thus helping the user identify and correct highlight issues.
libraw_pack_unpack_params_t and the gamma settings and other raw decoding options: Again, RawSpeed handles the unpacking of raw data. darktable, at the user level, does not allow direct manipulation of low-level parameters like gamma at the time of raw file reading. However, darktable's processing pipeline includes modules such as:

"input color profile": This module manages the conversion from the camera's color space to a working space. There might be profile options that influence how colors are interpreted from the beginning of the pipeline.
"exposure": As mentioned earlier, it allows adjusting the brightness of the image linearly.
Other tone and color adjustment modules (such as "tone curve", "levels", "color equalizer") allow precise control over the final appearance of the image, including the management of highlights and shadows.
To find the specific code in darktable that interacts with RawSpeed to read linear DNGs and potentially influence highlight management, you should explore the darktable sources on GitHub, especially the files in the following directories (keeping in mind that RawSpeed is an external library):

src/imageio/: This directory contains the code for managing image input and output, including the integration with RawSpeed. Look for files related to reading raw formats and specifically DNG.
src/processing/: This directory contains the code for the various image processing modules, including "highlight reconstruction", "filmic rgb", and "exposure". Examine how these modules analyze and modify image data, especially concerning high-brightness pixels.
The RawSpeed sources themselves (in the darktable-org/rawspeed repository) might contain detailed information about how linear DNG data is interpreted and how initial clipping is handled.
In summary:

darktable uses RawSpeed to read linear DNG raw files. While it doesn't directly expose the libraw_output_params_t and libraw_pack_unpack_params_t structures, darktable offers a variety of modules and options in its processing pipeline to effectively manage highlight clipping and adjust the tone and colors of raw images, including those from linear DNG files. Exploring the source code of darktable and RawSpeed on GitHub will give you a deeper understanding of the specific mechanisms involved.
Post Reply