A tone equalizer in darktable ?

I commented __DT_CLONE_TARGETS__ in the toneequal.c, but I still get errors in the .h files included:

[ 56%] Building C object src/iop/CMakeFiles/toneequal.dir/introspection_toneequal.c.obj
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:83,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:413:20: error: the call requires 'ifunc', which is not supported by this target
  413 | static inline void fast_guided_filter(float *const restrict image,
      |                    ^~~~~~~~~~~~~~~~~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:27,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:83,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/sse.h:30:9: error: the call requires 'ifunc', which is not supported by this target
   30 | #pragma omp parallel for simd default(none) \
      |         ^~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:99,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:401:11: error: the call requires 'ifunc', which is not supported by this target
  401 |   #pragma omp parallel sections
      |           ^~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:85,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:308:1: error: the call requires 'ifunc', which is not supported by this target
  308 |       LOOP(pixel_rgb_geomean);
      | ^
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:305:1: error: the call requires 'ifunc', which is not supported by this target
  305 |       LOOP(pixel_rgb_norm_power);
      | ^
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:302:1: error: the call requires 'ifunc', which is not supported by this target
  302 |       LOOP(pixel_rgb_norm_2);
      | ^
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:299:1: error: the call requires 'ifunc', which is not supported by this target
  299 |       LOOP(pixel_rgb_norm_1);
      | ^
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:296:1: error: the call requires 'ifunc', which is not supported by this target
  296 |       LOOP(pixel_rgb_value);
      | ^
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:293:1: error: the call requires 'ifunc', which is not supported by this target
  293 |       LOOP(pixel_rgb_lightness);
      | ^
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:85,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:290:1: error: the call requires 'ifunc', which is not supported by this target
  290 |       LOOP(pixel_rgb_mean);
      | ^
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:83,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:355:9: error: the call requires 'ifunc', which is not supported by this target
  355 | #pragma omp parallel for simd default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:336:9: error: the call requires 'ifunc', which is not supported by this target
  336 | #pragma omp parallel for simd default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:98:9: error: the call requires 'ifunc', which is not supported by this target
   98 | #pragma omp parallel for simd collapse(2) default(none) schedule(static) aligned(in, out:64) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:298:9: error: the call requires 'ifunc', which is not supported by this target
  298 | #pragma omp parallel for default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:269:9: error: the call requires 'ifunc', which is not supported by this target
  269 | #pragma omp parallel for default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:207:9: error: the call requires 'ifunc', which is not supported by this target
  207 | #pragma omp parallel for default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:169:9: error: the call requires 'ifunc', which is not supported by this target
  169 | #pragma omp parallel for default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:402:9: error: the call requires 'ifunc', which is not supported by this target
  402 | #pragma omp parallel for simd default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:390:9: error: the call requires 'ifunc', which is not supported by this target
  390 | #pragma omp parallel for simd default(none) \
      |         ^~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:379:9: error: the call requires 'ifunc', which is not supported by this target
  379 | #pragma omp parallel for simd default(none) \
      |         ^~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:99,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:374:19: error: the call requires 'ifunc', which is not supported by this target
  374 | static inline int pseudo_solve(float *const restrict A,
      |                   ^~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:355:19: error: the call requires 'ifunc', which is not supported by this target
  355 | static inline int transpose_dot_vector(float *const restrict A, // input
      |                   ^~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:335:19: error: the call requires 'ifunc', which is not supported by this target
  335 | static inline int transpose_dot_matrix(float *const restrict A, // input
      |                   ^~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:268:19: error: the call requires 'ifunc', which is not supported by this target
  268 | static inline int solve_hermitian(const float *const restrict A,
      |                   ^~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:239:19: error: the call requires 'ifunc', which is not supported by this target
  239 | static inline int triangular_ascent_safe(const float *const restrict L,
      |                   ^~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:220:19: error: the call requires 'ifunc', which is not supported by this target
  220 | static inline int triangular_ascent_fast(const float *const restrict L,
      |                   ^~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:191:19: error: the call requires 'ifunc', which is not supported by this target
  191 | static inline int triangular_descent_safe(const float *const restrict L,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:172:19: error: the call requires 'ifunc', which is not supported by this target
  172 | static inline int triangular_descent_fast(const float *const restrict L,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:124:19: error: the call requires 'ifunc', which is not supported by this target
  124 | static inline int choleski_decompose_safe(const float *const restrict A,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/choleski.h:99:19: error: the call requires 'ifunc', which is not supported by this target
   99 | static inline int choleski_decompose_fast(const float *const restrict A,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:85,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:280:20: error: the call requires 'ifunc', which is not supported by this target
  280 | static inline void luminance_mask(const float *const restrict in, float *const restrict out,
      |                    ^~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:230:13: error: the call requires 'ifunc', which is not supported by this target
  230 | static void pixel_rgb_geomean(const float *const restrict image,
      |             ^~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:200:13: error: the call requires 'ifunc', which is not supported by this target
  200 | static void pixel_rgb_norm_power(const float *const restrict image,
      |             ^~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:177:13: error: the call requires 'ifunc', which is not supported by this target
  177 | static void pixel_rgb_norm_2(const float *const restrict image,
      |             ^~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:153:13: error: the call requires 'ifunc', which is not supported by this target
  153 | static void pixel_rgb_norm_1(const float *const restrict image,
      |             ^~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:136:13: error: the call requires 'ifunc', which is not supported by this target
  136 | static void pixel_rgb_lightness(const float *const restrict image,
      |             ^~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:119:13: error: the call requires 'ifunc', which is not supported by this target
  119 | static void pixel_rgb_value(const float *const restrict image,
      |             ^~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:95:13: error: the call requires 'ifunc', which is not supported by this target
   95 | static void pixel_rgb_mean(const float *const restrict image,
      |             ^~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/luminance_mask.h:84:14: error: the call requires 'ifunc', which is not supported by this target
   84 | static float linear_contrast(const float pixel, const float fulcrum, const float contrast)
      |              ^~~~~~~~~~~~~~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:83,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:368:20: error: the call requires 'ifunc', which is not supported by this target
  368 | static inline void quantize(const float *const restrict image,
      |                    ^~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:349:20: error: the call requires 'ifunc', which is not supported by this target
  349 | static inline void apply_linear_blending_w_geomean(float *const restrict image,
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:330:20: error: the call requires 'ifunc', which is not supported by this target
  330 | static inline void apply_linear_blending(float *const restrict image,
      |                    ^~~~~~~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:257:20: error: the call requires 'ifunc', which is not supported by this target
  257 | static inline void box_average(float *const restrict in,
      |                    ^~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:151:20: error: the call requires 'ifunc', which is not supported by this target
  151 | static inline void variance_analyse(const float *const restrict guide, // I
      |                    ^~~~~~~~~~~~~~~~
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:92:20: error: the call requires 'ifunc', which is not supported by this target
   92 | static inline void interpolate_bilinear(const float *const restrict in, const size_t width_in, const size_t height_in,
      |                    ^~~~~~~~~~~~~~~~~~~~
In file included from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/fast_guided_filter.h:27,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/iop/toneequal.c:83,
                 from C:/msys64/home/marco/darktable-2.7-equalizer/darktable/build/src/iop/introspection_toneequal.c:77:
C:/msys64/home/marco/darktable-2.7-equalizer/darktable/src/common/sse.h:22:20: error: the call requires 'ifunc', which is not supported by this target
   22 | static inline void dt_simd_memcpy(const float *const restrict in,
      |                    ^~~~~~~~~~~~~~
make[2]: *** [src/iop/CMakeFiles/toneequal.dir/build.make:68: src/iop/CMakeFiles/toneequal.dir/introspection_toneequal.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:3455: src/iop/CMakeFiles/toneequal.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

__DT_CLONE_TARGETS__ is contained in the following files

./src/common/darktable.h
./src/common/fast_guided_filter.h
./src/common/luminance_mask.h
./src/common/sse.h
./src/iop/choleski.h
./src/iop/toneequal.c

Should I try to remove it from all files ?

Windows 10 / MinGW64 / gcc 9.2.0

I can compile Tone Equalizer under Ubuntu just fine

could also be that gcc 9.2.0 is more strict again.

I build on GCC9 with no issue.

It’s either the OpenMP #pragma omp declare simd or the __attribute__((target_clones())) decorators that fails on Win.

or just replace

#if __has_attribute(target_clones)
#define __DT_CLONE_TARGETS__ __attribute__((target_clones("default", "sse2", "sse3", "sse4.1", "sse4.2", "popcnt", "avx", "avx2", "avx512f", "fma4")))
#else
#define __DT_CLONE_TARGETS__
#endif

by

#define __DT_CLONE_TARGETS__

in darktable.h, line 99.

with this replacement tonequalizer compiles on win10/mingw

Yes, confirmed.
However, when activating the module I get the message: “tone equalizer buffers are ill-aligned, please report the bug to the developers”

Marco

I have added an extra check in the latest commit so the target clones are disabled if Win32 is detected. It’s a shame for Windows users though, because they won’t get the best optimization for their CPU, but… they choose the wrong OS, they should live with it.

The non-alignment of buffers is more concerning though. I have to track which buffer allocation does not align properly.

Aurelien, Thanks for all your work on this module and your explanations thus far. I have built and installed it and I am planning to test it out tonight. I had two quick questions and forgive my ignorance on any of the points but #1 when I complied your toneequalizer branch it noted that you are a good number of commits ahead of the master branch but the version shows as 2.5 and not 2.7 or higher. Does using this with any files the have been edited on a 2.7 dev build create any issues with previous edits…of course i will back things up before trying but just curious and secondly other than this post are there any other examples or documentation that you have created or are aware of for the use of this module. I will just have a go at it but if my testing could be more informed that would be gravy…thanks again.

#1 when I complied your toneequalizer branch it noted that you are a good number of commits ahead of the master branch but the version shows as 2.5 and not 2.7 or highe

The 2.5 tag is purely a git stuff, I never updated the tags. It means nothing for the actual program.

Does using this with any files the have been edited on a 2.7 dev build create any issues with previous edits…of course i will back things up before trying but just curious

It should not create issues per se, apart from the usual “this is still unstable stuff until proved stable” I guess.

secondly other than this post are there any other examples or documentation that you have created or are aware of for the use of this module.

Not yet.

Thanks for clarifying…

Module merged in darktable master today.

12 Likes

Superb! Merci!

Claes en Lund, La Suède

Excellent! I am happy to test it!

Excellent … I have been so looking forward to this!

Congratulations, great work. Looking forward to try it once Pascal merges my fix :wink:

Compiles fine on Windows 10.
Testing it, it seems to work, but…
On pictures taken in bright sunlight, with quite high dynamic range (main histogram spread end to end), the tone equalizer histogram covers only a small portion of the luminosity range

Cattura3

which leaves very limited room for adjustments, only 2-3 sliders / points have an effect.
What’s going wrong ?

Marco

I’m getting the same issues with all my pictures that have an histogram stretch from left to right in the main darktable histogram while the histogram in tone equalizer is compressed on the right side with only 3-4 sliders effective.

I will post a screenshot tomorrow when I have access to my Mac.

Nothing is going wrong. The guided filter is applied iteratively 2 or 3 times on top of itself, depending on the preset you choose. Depending of the feathering factor used, the guided filter tends to average the luminance piece-wise, thus compress the histogram around the average luminance of your picture.

Screenshot_20190924_110347

To compensate for that, in the masking tab, you can use the mask exposure and contrast compensation. The exposure compensation will slide the histogram to the left or right, and the contrast will dilate/compress it around -4 EV. To help you setting them, you get a bar representing the histogram spreading just above those settings. The bright bar represent the coverage of the first and last deciles of the histogram, so you get 80 % of the histogram in it. Orange highlights appear when a part of the histogram is outside the tone equalizer settings range.

You get auto-tuners to help you, but they work well only when mask quantization is set to 0.

2 Likes

1h45 of explainations about how to use filmic RGB and the new equalizer in a no-nonsense workflow. Also, my first video in English.

27 Likes