Skip to content

Markesteijn and VNG demosaic fixes#20631

Open
jenshannoschwalm wants to merge 2 commits intodarktable-org:masterfrom
jenshannoschwalm:markesteijn_fixes
Open

Markesteijn and VNG demosaic fixes#20631
jenshannoschwalm wants to merge 2 commits intodarktable-org:masterfrom
jenshannoschwalm:markesteijn_fixes

Conversation

@jenshannoschwalm
Copy link
Collaborator

Markesteijn demosaicer fixes

  1. The CPU code deserves the better border calculation as we do for OpenCL since very long. There is a small performance penalty but with clearly better results. I was likely just overseen for many years.
  2. The VNG linear interpolation got modifications to handle borders.
  3. Fix subtle differences between OpenCL and CPU for low levels.

Various VNG demosaicer fixes

  1. Fix OpenCL VNG full interpolation, we must not touch the outermost 2 pixels, they have been interpolated already in the linear phase.
  2. Ensure identical results for VNG initial 1-photosite borders.
  3. Fix VNG final green mixing for bayer4 sensors. Do this at the end of processing for both CPU and GPU code.
  4. Fix some maths leading to different results OpenCL vs CPU
  5. Added tooltip why VNG4 is still a valuable demosaicer.

@TurboGit this definitely changes expected output for all xtrans related tests as we change the border maths. (0065 0066 0068 0100 0145 0146 0165 0173) All related tests show less differences btw.

For these parts all is good to me so ready to be merged.

Pending work on demosaicers: Some deduplication of PPG/RCD/LMMSE border code, still too large GPU/CPU differences for green averaging for some reason.

after that pending work it will be the work on tests with large diffs ...

1. The CPU code deserves the better border calculation as we do for OpenCL since very long.
   There is a small performance penalty but with clearly better results.
   I was likely just overseen for many years.
2. The VNG linear interpolation got modifications to handle borders.
3. Fix subtle differences between OpenCL and CPU for low levels.
1. Fix OpenCL VNG full interpolation, we must not touch the outermost 2 pixels,
   they have been interpolated already in the linear phase.

2. Ensure identical results for VNG initial 1-photosite borders.

3. Fix VNG final green mixing for bayer4 sensors.
   Do this at the end of processing for both CPU and GPU code.

4. Fix some maths leading to different results OpenCL vs CPU

5. Added tooltip why VNG4 is still a valuable demosaicer.
@jenshannoschwalm jenshannoschwalm added bugfix pull request fixing a bug scope: image processing correcting pixels release notes: pending OpenCL Related to darktable OpenCL code labels Mar 22, 2026
@jenshannoschwalm jenshannoschwalm added this to the 5.6 milestone Mar 22, 2026
@TurboGit
Copy link
Member

All tests have less or equal differences, that's great. There is one exception where the CPU vs GPU diff was below 17000 and is now > 38000.

Test 0162-demosaic-lmmse
      Image mire1.cr2
      CPU & GPU version differ by 38325 pixels
      CPU & GPU large difference > 17000
      CPU vs. GPU report :
      ----------------------------------
      Max dE                   : 3.38218
      Avg dE                   : 0.00744
      Std dE                   : 0.06986
      ----------------------------------
      Pixels below avg + 0 std : 98.63 %
      Pixels below avg + 1 std : 98.63 %
      Pixels below avg + 3 std : 98.72 %
      Pixels below avg + 6 std : 99.13 %
      Pixels below avg + 9 std : 99.59 %
      ----------------------------------
      Pixels above tolerance   : 0.00 %
 
      Expected CPU vs. current CPU report :
      ----------------------------------
      Max dE                   : 5.01068
      Avg dE                   : 0.00732
      Std dE                   : 0.07183
      ----------------------------------
      Pixels below avg + 0 std : 98.59 %
      Pixels below avg + 1 std : 98.61 %
      Pixels below avg + 3 std : 98.78 %
      Pixels below avg + 6 std : 99.27 %
      Pixels below avg + 9 std : 99.65 %
      ----------------------------------
      Pixels above tolerance   : 0.00 %
 
  FAILS: image visually changed
         see diff.png for visual difference
         (39389 pixels changed)

@jenshannoschwalm
Copy link
Collaborator Author

Yes i see that too.

  1. It's definitely not demosaicer related as LMMSE does not have a GPU path :-)
  2. Interesting insofar as the dump-diff complete shows 3 subimages so there must be some INF or NAN in pipe. (likely after colorin)
  3. For me this just emphases there is still pending work but nothing related to this PR :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug OpenCL Related to darktable OpenCL code release notes: pending scope: image processing correcting pixels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants