Skip to content

Add contrast and texture step one - #21590

Merged
TurboGit merged 1 commit into
darktable-org:masterfrom
jandren:add-contrast-and-texture-step-one
Aug 8, 2026
Merged

Add contrast and texture step one#21590
TurboGit merged 1 commit into
darktable-org:masterfrom
jandren:add-contrast-and-texture-step-one

Conversation

@jandren

@jandren jandren commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Step one of implementing and merging a new scene referred local contrast module, named "contrast & texture".
See: #20626 (comment)

This is based on work by @wilecoyote2015 which presented the original idea and @Christian-Bouhon who took it further with integrating multiple sliders for different detail levels and some per-pixel operations. This PR is my attempt at making something cleaner and reviewable from those attempts and to then follow up with more functionality later.

The core principle of the module is to modifiy the log difference between a luminance estimate and its low pass version filtered using the exposure invariant guided filter (eigf, same as in tone equalizer). Its in this way easy to target different detail sizes.

It works well for clouds and landscapes:
A7S00227
A7S00227_01

Portraits for more punchy skin textures (there have also been good examples of smoothing over at discuss earlier):
A7S08784
A7S08784_01

Noise can suppressed quite well when needed and the effect is directly visible in the details preview (mask symbol to the right of the gain slider):

ISO 100 noise bias = 0.0001
ISO 100 noise bias = 0.0001

ISO 25600, noise bias = 0.0001
ISO 25600, noise bias = 0.0001

ISO 25600, noise bias = 0.1
ISO 25600, noise bias = 0.1

@TurboGit TurboGit added this to the 5.8 milestone Jul 22, 2026
@TurboGit
TurboGit self-requested a review July 22, 2026 09:37
@TurboGit TurboGit added priority: low core features work as expected, only secondary/optional features don't feature: new new features to add scope: image processing correcting pixels documentation: pending a documentation work is required release notes: pending labels Jul 22, 2026

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments after a first code review.

Comment thread src/libs/modulegroups.c Outdated
Comment thread src/iop/contrast.c Outdated
Comment thread src/iop/contrast.c Outdated
Comment thread src/iop/contrast.c Outdated
Comment thread src/iop/contrast.c Outdated
Comment thread src/iop/contrast.c Outdated
Comment thread src/iop/contrastntexture.c
Comment thread src/iop/contrast.c Outdated
Comment thread data/kernels/programs.conf Outdated
Comment thread src/iop/contrast.c Outdated
Comment thread src/libs/modulegroups.c Outdated
Comment thread src/libs/modulegroups.c Outdated
Comment thread src/common/iop_order.c Outdated

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question, what is the status? Do you want this to be merged as a first iteration or want to wait for adding more?

On my side a second code review, see new comments.

And tested too, works nice to me.

@jandren

jandren commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@TurboGit I feel done with what I defined as the first step in the issue discussion.
My idea was to merge this now and then continue to work on additional features in a new branch, but do what is best for you as maintainers and darktable. I'm flexible!

Next steps are:

  • Add multiple levels (explore highpass vs bandpass modes)
  • Add shadows and highlights control based on the low pass like a simplified tone equalizer, worked really well in my testing earlier.

@TurboGit

TurboGit commented Aug 7, 2026

Copy link
Copy Markdown
Member

@jandren : Thanks, and fine by me with integration now as a first step. Code look good to me and it works nice on my side.

One point that I'd like to discuss:

  • To me this is replacing the current local contrast so for the "scene referred" module group I would have replaced contrast local by this module (that is, removing local contrast. I don't see a good reason to keep both except for confusing our users).

Do you agree with that? Otherwise what are the arguments to keep both?

So if you agree:

  • modules : all : add it just after local contrast into the tonality tab.
  • workflow : scene referred : replace local contrast by new contrast & texture.

@TurboGit

TurboGit commented Aug 7, 2026

Copy link
Copy Markdown
Member

Ok for squashing all before merging?

Enable scene refered editing of details in images.
The core principle of the module is to modifiy the
log difference between a luminance estimate and its
low pass version filtered using the exposure invariant
guided filter (eigf, same as in tone equalizer).
Its in this way easy to target different detail sizes.

Work based on initial idea by
Co-authored-by: bjoern <wilecoyote2015@gmail.com>
And further efforts by
Co-authored-by: Christian Bouhon <christian.bouhon@outlook.be>
Co-authored-by: Dan Zwell <devel@zwell.net>
@jandren
jandren force-pushed the add-contrast-and-texture-step-one branch from e85d93f to 8c1ca12 Compare August 8, 2026 13:46
@jandren

jandren commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

I do agree on this being the replacement module for the display refereed module "local contrast". Made the needed changes for that in the module groups.

Branch is rebased and squashed with contributions as Co-authors.

@TurboGit

TurboGit commented Aug 8, 2026

Copy link
Copy Markdown
Member

@jandren : Perfect then, I'll do another testing round and will merge if all is ok.

@jenshannoschwalm

Copy link
Copy Markdown
Collaborator

I tried, very nice results to me and not overloaded.

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, a glitch you've removed the "local contrast" from the "all modules" group :)

I'll fix just after merging.

@TurboGit
TurboGit merged commit 1067c65 into darktable-org:master Aug 8, 2026
6 checks passed
@Donatzsky

Copy link
Copy Markdown

I'm getting a compiler segfault when building current master.

[ 77%] Built target colorequal
[ 77%] Generating introspection_contrastntexture.c
[ 77%] Building C object lib/darktable/plugins/CMakeFiles/contrastntexture.dir/introspection_contrastntexture.c.o
[ 77%] Linking C shared module libcontrastntexture.so
during IPA pass: cp
lto1: internal compiler error: Segmentation fault
0x248dc58 diagnostics::context::diagnostic_impl(rich_location*, diagnostics::metadata const*, diagnostics::option_id, char const*, __va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x2490267 internal_error(char const*, ...)
        ???:0
0xb3205c ipa_ref::remove_reference()
        ???:0
0x7ec1a7 cgraph_edge::redirect_callee(cgraph_node*)
        ???:0
0xaab8ce ipa_fn_summary_t::duplicate(cgraph_node*, cgraph_node*, ipa_fn_summary*, ipa_fn_summary*)
        ???:0
0x80e18e cgraph_node::create_virtual_clone(vec<cgraph_edge*, va_heap, vl_ptr> const&, vec<ipa_replace_map*, va_gc, vl_embed>*, ipa_param_adjustments*, char const*, unsigned int)
        ???:0
/usr/lib/gcc/x86_64-pc-linux-gnu/16/lto1 -quiet -dumpbase ./libcontrastntexture.so.wpa -march=x86-64 -mno-omit-leaf-frame-pointer -mtune=generic -g -g -g -O2 -O3 -O3 -O2 -O3 -O3 -Werror=format-security -Wshadow -Wtype-limits -Wmaybe-uninitialized -Wno-error=varargs -Wformat-truncation=0 -Wno-error=address-of-packed-member -fno-openacc -fcf-protection=full -fPIC -fno-plt -fexceptions -fstack-clash-protection -fcf-protection=full -fno-omit-frame-pointer -ffile-prefix-map=/home/nis/.cache/aurutils/sync/darktable-git/src=/usr/src/debug/darktable-git -fopenmp -ffast-math -fno-finite-math-only -fexpensive-optimizations -fltrans-output-list=/tmp/cc1eus9G.ltrans.out -fwpa=4 -fresolution=/tmp/ccN1mVnp.res -flinker-output=dyn @/tmp/ccAxeWag
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues> for instructions.
lto-wrapper: fatal error: /usr/bin/cc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [lib/darktable/plugins/CMakeFiles/contrastntexture.dir/build.make:209: lib/darktable/plugins/libcontrastntexture.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:9149: lib/darktable/plugins/CMakeFiles/contrastntexture.dir/all] Error 2
make: *** [Makefile:156: all] Error 2
make: Leaving directory '/home/nis/.cache/aurutils/sync/darktable-git/src/darktable/build'

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

Labels

documentation: pending a documentation work is required feature: new new features to add priority: low core features work as expected, only secondary/optional features don't release notes: pending scope: image processing correcting pixels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants