Submitted by kevinjian on
Forums:
I wrote a simple program to convert input RAW data into RGB and display it. The RAW data comes from a DNG file, so I know the white balance parameters and black level values. My basic processing pipeline is as follows:
First subtract the black level from the RAW data, then apply demosaicing, followed by white balance adjustment, and finally perform gamma correction.
However, I noticed some differences between my output RGB image and the TIFF exported by RawDigger in RGB Render mode. Compared to RawDigger's TIFF output, my simulated results appear somewhat hazy - whites aren't as bright and blacks aren't as deep.
I'm attaching download links(https://drive.google.com/drive/folders/1oRoPo7VfpZfrHl7tskpa-H18X0t-LdaY...) for both images for reference:
- The file named "rawdigger.tif" is exported from RawDigger (in RGB Render mode)
- The file named "sim.bmp" is my program's output using the described pipeline
- The file named "exif.txt" is exif info.
- The file named "src.dng" is original DNG file.
In my simulation program:
- Black level value used: 64
- White balance gains: wb_gains = [1/0.5547, 1, 1/0.6563]
- Gamma value: 2.2
Could you please help identify what might be causing these discrepancies?
Image:


RawDigger uses LibRaw
Submitted by lexa on
RawDigger uses LibRaw (opensource) for RGB rendering.
After quickly scanning the
Submitted by kevinjian on
After quickly scanning the relevant modules in LibRaw, I found the following:
1. After AWB, the data is scaled so that the maximum value reaches 65535 (the maximum for 16-bit). This step causes the output TIFF/PPM to have a maximum brightness close to 65535, resulting in increased contrast.
2. CCM is applied by default. To disable it, add `-o 0` to the command line:
```
dcraw_emu.exe -v -o 0 -T input.dng
```
3. When outputting to TIFF, a gamma mapping is applied (typically with a value of 1/2.2=0.45), which further increases contrast. To avoid this, use the following command:
```
dcraw_emu.exe -v -o 0 -4 input.dng
```
Therefore, RawDigger’s RGB render mode likely includes:
1. Rescaling of AWB-adjusted data;
2. No CCM applied;
3. Gamma applied.
CCM is either applied
Submitted by lexa on
CCM is either applied (default) or not, depending on Preferences - Display Settings - Camera color profile setting
Understood. The "built-in"
Submitted by kevinjian on
Understood. The "built-in" CCM closely resembles the "no profile (raw color)" rendering, whereas the "embedded in RAW" version appears more vivid.
Not so.
Submitted by lexa on
Not so.
Built in => color matrix built in LibRaw (equal to dcraw_emu -M)
Raw color => no profile (dcraw_emu -o 0)
Embedded => use profile from RAW (if any), equal to dcraw_emu +M
Add new comment