Clarity in darktable

We have to tattoo it in our arm! hahaha

Experience is the best reminder…I have quite a few presets with low opacity multiply so I just use them….if I had experimented more with the new one I would have likely discovered the nuance of it. I love your edits by the way. I think that you and Boris are great ambassadors for the software. There is a lot of math and technical talk around DT but you and Boris put some creative and artistic flare into it……

3 Likes

The problem of “reverse” blend modes in scene referred is that they respond in a strange way to masks.
Unless I am missing something, there is no way to restrict the effect to a part of the image with a drawn or parametric mask, some effect is applied also outside the mask.

2 Likes

I think only reverese multiply is doing that the other two don’t seem to …ie divide and substract…at least in my limited experience

https://github.com/darktable-org/darktable/issues/7464#issuecomment-766158145

I’m “studying” the code where these blending modes are done “blendif_rgb_jzczhz.c” but I have some difficulties to understand everything.

  • I see that “blend fulcrum” slider is related with the “p” value in the functions (but I didn’t find where it’s created this “p”.
  • In “blend_subtract” and “blend_subtract_reverse” the “b” array goes till “j+3” and in others goes to “j+DT_BLEND…”

I’m not a software man as you can see. If I understand everything I will try to find where the problems are. Because I’ve detected they the mask is lost when I do some operations (I have to identify exactly when it happens)

To understand why a mask doesn’t seem to be effective, you need to understand the architecture of how blending modes are working. REfer to the following diagram in the user manual:
https://www.darktable.org/usermanual/en/darkroom/processing-modules-and-pixelpipe/the-anatomy-of-a-module/

This shows a case where, for example, we have a normal “Multiply” operation. See the slider at the top right, it takes a copy of the input image, and a copy of the output of the module+blending operator. The position of the slider for each pixel slider is then controlled by the value of the mask at that pixel position. If the opacity is set to 0, you get 100% the input image, and if the opacity is 1 you get 100% of the output from the module+blend operation.

In the case of multiply reverse, the top of the slider doesn’t connect to the input image, it cnnects to the output of the module, just before the blend operation. This means the final output of the slider is a mix between the module output (eg. local contrast enhancement, for the local contrast module) and the output of the blend operator (eg. multiplying the pixel from the input image with the pixel from the output of the contrast enhancement, in the case of a multiply blending operation). In this case, both sides of the slider input are coming from the output side of the module, which means that the effect of the module (eg. local contrast) will be present in some form regardless of where the mask sets the slider.

Probably we should provide a second copy of that diagram showing the logic of the “reverse” blending modes. The documentation is a bit vague on blending modes in general, passing the buck to the GIMP documentation. I think this was an attempt to keep the documentation from growing too much and being difficult to maintain as new blending modes are added, but it does make this aspect of the darktable behaviour more opaque.

1 Like

Still subtract and divide should show this and they don’t. The author admits they are more inverse than reverse so it’s not perfectly clear…

Subtract works like this:

BLEND_SUBTRACT:
      final_output = input * (1.0f - opacity) + fmax(input - blend_parameter * module_out, 0.0f) * opacity

BLEND_SUBTRACT_REVERSE:
      final_output = input * (1.0f - opacity) + fmax(module_out - blend_parameter * input, 0.0f) * opacity

Divide works like this:

BLEND_DIVIDE:
      final_output = input * (1.0f - opacity) + input / fmax(module_out * blend_parameter, 1e-6f) * opacity

BLEND_DIVIDE_REVERSE:
      final_output = input * (1.0f - opacity) + module_out / fmax(input * blend_parameter, 1e-6f) * opacity

Like I said, I think this sort of information should properly be captured in the user manual.

1 Like

I was not disputing the formula’s merely pointing out that with reverse multiply you get an effect outside the mask due to the layer that is blended but with the other 2 “reverse” modes don’t behave that way and so the author proposed that maybe they should be renamed as it was misleading somewhat…Maybe the situation has been updated…

I have found it.
I wanted to say that there is a bug with the masks and I know now when it happens:

  • activate local contrast module
  • create a mask RGB (scene)
  • deactivate local contrast module
  • activate other module (velvia for example)
  • reactivate local contrast
  • …the mask is lost. And if you try to paint, automatically the mask GUI is deactivated

I think that it’s a bug. And I’m trying to find the origin. But maybe is a too difficult task for me.

2 Likes

The recent User Manual has an entry:
“modules to avoid”

The lines below are from there:
“There are a number of modules which are no longer recommended for use within a scene-referred workflow”.

I noticed that in your workflow a scene referred operation was followed by a module that was labelled as one to be avoided.

I have no idea about the fine technicalities of the issue but I wonder if the cause of your problem has something to do with the above mismatch.

„not recommended to use“ doesn’t imply that this module messes up everything. You need to know what you‘re doing - it can cause a messup for one image and be fine for another…
If something was messed no one can give help without having the image and xmp :wink:

2 Likes

It just means using these modules might introduce artifact as they require values to be in the range of 0 to 1.

1 Like

Could you please clarify the following: Why do reverse blend modes only appear in the drop down list when the blending option RGB (scene) is selected?

Hi’ @Matt_Maguire

Thank you for a very good explanation.

I don’t think that the GIMP documentation explains the fulcrum slider.

Take the multiply blend mode as an example. Every pixel in the output is multiplied with the corresponding pixel in the input and the result is divided by 255. Unaffected pixels are pixels with a value of 0 or 255.

The Darktable manual states:

“Some blend modes depend on a fulcrum for their operation. This fulcrum usually defines the point at which the blend mode results in a “no-operation” which may be white or grey depending on the blend mode. The additional blend fulcrum parameter allows the position of this fulcrum to be adjusted where blending is performed within the RGB scene-referred color space.”

What does the fulcrum slider do in the multiply blend mode?

1 Like

I don’t really understand much about how the blend modes work (which is one of the reasons I haven’t tackled the documentation for them yet). My understanding, though, is that the purely arithmetic blend modes (multiply, divide, add, subtract) don’t depend on the fulcrum at all.

I’m going to start working on a draft now, that at least no longer relies on GIMP docs - hopefully others with more knowledge will chime in with some improvements.

Edit: I see the fulcrum does do something in blend mode multiply. I clearly need to do some more research.

Yes, I was going to say…

I’ve posted a very draft revision of the documentation on github if anyone wants to take a look. Bear in mind that there’s likely to be stuff that’s wrong in here. I’ve mostly constructed it from code that I only half understand.

3 Likes

The documentation you have posted states:

“Multiply the pixel values of the input and output together. When blending in the “RGB (scene)” color space, this value is further multiplied by a value proportional to the “blend fulcrum”.”

So if you move the fulcrum slider to the right all pixels will be multiplied by a factor > 1 (everything becomes lighter), and if you move the slider to the left the pixels will be multiplied by a factor < 1 (everything becomes darker).

This makes good sense….:+1::+1:.

Thank you for a quick response.

@asn
Could you please give some explanation about contrast equalizer + subtract modes?
I played with it for awhile and have not seen any improvement over normal blend on the pics I tried. My regular workflow includes clarity preset with strenght down to 0.4 as a starting point.