[Suggestion] Simplify Tone Equalizer

Two things about the bar and histogram display.

The gray bar spans 80% of the histogram “surface”. Your example has a fairly long “tail” towards the shadows, and a larg peak in the light areas. So the gray bar will cover most of the light areas, but “ignore” the shadow part.

Now, exactly how much of the histogram the bar should cover can be discussed, but 100% coverage doesn’t work in practice.

E.g. xtreme highlighs, like lamps, would throw off the bar in an impossible way: “tone equalizer” comes before filmic in the execution pipeline, so channel values are not restricted to the interval 0…1 yet. That means extreme highlights could end up at values of 3, 4, … with the rest of your image nicely in the 0-1 range.

Noise is also a problem: in the shadows, small intensity variations can give large variations in EV. And noise is just that, small intensity variations. So you could end up with very low EV values (far outside the useful range of your image).

In addition, the lightness scale in the tone equalizer is linear in EV, that means exponential in lightness (each EV doubles the physical lightness). This ‘favours’ the shadows, and more or less mirrors human perception. The image histogram at the top of the right sidebar is linear in lightness, which favours the hightlights and corresponds to the actual light energy.

So forcing the mask or an indicator to cover 100% of your image at this point in the pipeline is just plain bad.

Since you can see the mask overlayed on your image (“display exposure mask” at the bottom of the tab), you should still have a good idea how the mask coverage is, and how well suited to your purpose. The mask is a tool here, not the final result.

And how often do you really target the whole tonal range with the tone equalizer? There are simpler tools to adjust global contrast…

2 Likes

Yes, that is clear

I don’t quite agree, but see below.

That is also clear

That is clear as well.

That is also understood

Hence why I proposed a zoomable interface for the advanced tab, so that we are not stuck with nodes that are 1EV apart. That way you could disregard those “long tails”. Contrast compensation is there for that reason, but if used agressively, will create artifacts and mess up with the guided filter. What @kofa suggested is so far the best solution for me, although it’s not perfect, since you can only use the module that way via shortcuts and not through the GUI.

Agreed

Very often. I try to use the module based on what @anon41087856 shows here, and he uses the module on the whole image:

Module usage could be summed up in the following 3 usecases:

  • For increasing contrast, as long as you don’t care about also increasing local contrast use no filter.
  • For increasing contrast while preserving local contrast, use guided filters (I won’t go into the differences here).
  • For compressing dynamic range while preserving local contrast (which I believe is one of the most important usecases, and most of what @anon41087856 demonstrates in the video) use guided filters.

The part of the image where you do any of the 3 is up to you. The problem is that, say you want to focus on a very specific region, like the shadows of the image (leaving noise aside, I mean the actual darker parts of the image that you want to affect). To expand the histogram and have more nodes to control them you need to increase mask contrast and adjust mask exposure accordingly. The problem with that, is that the mask will start to fall apart quickly, creating artifacts. But if you don’t increase contrast you don’t have enough nodes.

Now, let’s look at what happens in each of the three usecases, when boosting the contrast enough to focus on only the shadows, for example:

  • Increase global and local contrast, no GF: there is no contrast compensation, so no problem.
  • Increase contrast and preserve local contrast, GF: Possible artifacts.
  • Compress dynamic range and preserve local contrast, GF: Possible artifacts, and if you compress DR in areas with too similar lightness value, the GF can only do so much, local contrast will decrease (although probably not as much as with no GF).

That’s why, despite what @kofa just showed us, I believe that, and if the technical difficulties are indeed solvable (proportionally scalable nodes), having a zoomable interface in the advanced tab instead of fixed nodes as well as a real histogram in the masking tab could be a good solution. If there is no contrast compensation, in theory, contrast wouldn’t mess with the guided filter, hopefully minimizing/avoiding the artifacts.

If not, the shortcuts he showed us, already make the module much easier to use for me.

Cheers!

Not breaking it down in to use cases I think in the end its to allow it to be fast enough to not kill the pipeline…the pipeline is triggered so often that a really slow module would impact performance. So if you are stuck with 8 or 9 points and you go to 0.1 ev nodes then you have a range span of 1EV …would that be useful?? I’m just asking not trying to be difficult…

Obviously, if my suggestion is possible, but brings darktable to its knees, that is not a viable solution.

0.1EV, 0.3EV, 0.8EV… Whatever you might need. That’s what I mean with a zoomable interface. The EV values change, but the nodes are proportionally at the same distance from each other, instead of fixed at 1EV separation.

Remember we are talking about the mask, and the mask only. If after tweaking the mask’s settings, the mask’s contrast decreases, and the mask’s dynamic range spans let’s say 2EV in total, then 9 nodes at 0.1EV distance would control 1EV of the mask, which in turn would control half of the final image, giving you all the nodes to tweak that half, and you wouldn’t need exposure or contrast compensation, hopefully then mitigating or avoiding artifacts resulting from the latter.

All this assuming my idea is possible.

But the mask’s range is fixed at 8EV (9 nodes for 8 intervals). So your nodes are always 1EV apart relative to the mask
What you change with the sliders is which part of the image histogram is covered. And the display of the mask will be affected by the filmic module later in the pipeline

I’m not sure I understand what you mean. EVs are EVs, they are not relative to the mask. The working range of the module is fixed at 8EV with 9 nodes at 1EV distance.

What we change with the top sliders in the masking tab is the kind of mask we are creating, which in turn reduce the mask’s contrast, so its dynamic range.

What we change with exposure/contrast compensation is the position (exposure) and spread (contrast) of the mask, so we can use more nodes to control the final image. If those values are pushed too hard, artifacts are introduced.

What I’m advocating for is that the tone EQ is not fixed at 8EV, so we can work with a lower contrast mask, and still have 9 nodes to control the final result, hopefully mitigating/avoiding artifacts.

If I understand correctly, you’d like to stretch and offset the scale of the X-axis to fit the histogram.
Again, if I understand correctly, the exposure and contrast adjustment scale the data to fit the pre-defined section of the X-axis, between -8EV and 0 EV.

What is the difference between your method (positioning and scaling the X-axis to fit the (to-be-manipulated part of the) histogram), and the other (positioning / scaling the histogram (exposure and contrast, respectively) so (the to-be-manipulated part of) it fills the X-axis (between -8 EV and 0 EV))?

One (your way) appears to say:
‘The object I want to manipulate is too small, only 8 mm; one edge is at 3.5 cm, the other at 4.3 cm. Let’s get another ruler that has a millimetre scale, and slide it so that the object gets between the 0 mm and 8 mm marks. I’ll read off data using my new ruler using the mm scale and enter the numbers in my calculations.’ The left edge will read 0 (mm), the right edge 8 (mm), the other points distributed between them.

The other:
‘Let’s make a 10x enlarged copy of the object, so it is 8 cm long; now let’s slide it to the left so that it fits between the 0 cm and 8 cm marks on my ruler. I’ll read off my data using my original ruler, using the cm scale, and enter the numbers in my calculations.’ The left edge will read 0 (cm), the right 8 (cm), the rest nicely distributed between those.

Yes to both.

That’s right, you got what I meant. The disadvantage of the second method (making an enlarged copy of the object, AKA mask contrast compensation) is that if the values are pushed too much, the mask and the guided filter will start to break and create artifacts. Going along with your metaphor, it’s the same as when you enlarge a photo beyond its resolution. The image will start to fall apart.

My method (getting a smaller ruler), assuming it is technically possible, would hopefully avoid those artifacts, since after the mask is created it is not altered by additional post-processing (exposure and contrast).

Are all masks equally vulnerable to the artifacts that you are talking about…I am more a visual learner so if you have a good example I would love to see it…by all masks I mean using a different norm…they seem to create wildly different masks and other than experimentation I really have no idea how to target the mask with any of them…ie is one better for flatter images and one better for more contrasted images etc…it would be nice if there was at least a hint of why each exists as an option when creating the mask…

I believe you should use the luminance estimator that gives you the most amount of contrast in your mask.

In terms of the types of guided filters, from the manual:

  • no: Do not smooth the mask (the effect is the same as using normal tone curves). When the module is used to compress dynamic range, this option can cause compression of local contrast. This can be useful when increasing (local and global) contrast.
  • guided filter: Use the original guided filter algorithm to blur the mask while attempting to preserve edges. One of the limitations of this algorithm is that the guided filter is exposure-sensitive, meaning that shadows tend to be blurred more than highlights. Note that this limitation can sometimes be an asset: if one wants to lighten shadows a lot, the guided filter can provide very good local contrast preservation.
  • average guided filter: Use this option in cases where the effect of the guided filter is too strong. In this mode, a geometric mean is taken between the output of the original guided filter algorithm and the output given by the no option.
  • eigf (default): The exposure-independent guided filter solves the problem of the original guided filter, in that it makes the degree of blurring independent of the exposure. This means the degree of blurring applied to the highlights and the shadows regions should be about the same. This improved algorithm is now the default option.
  • averaged eigf: This option takes the geometric mean between the eigf mask and the mask generated by the no option, and is useful in cases where the degree of blurring in the mask needs to be mitigated.

But the ‘resolution of the image’ won’t be improved by using a millimetre scale instead of centimetres. If the edge is blurry, you may say it’s at 2 cm, but if you measure using mm, you’ll see it covers everything from 19 mm to 22 mm, for example.
Scaling the axis / using a mm-scaled ruler to measure is also a form of zooming / enlarging. I don’t think you’d win anything.

If you get artefacts in the mask when stretching it, then those artefacts were probably there from the start, only you didn’t see them until you stretched the histogram by increasing the contrast.

1 Like

Thanks for your input…the filter types are pretty clear…and I guess if I understood the math better maybe the obvious use for the estimators would also be clear but just running through them creates wildly different masks…I guess if I spend more time with it maybe I will find my sweat spot….actually I rarely do spend much time on the mask….maybe for a troublesome image otherwise I have come to just use one of the presets as needed and then tweak that……I am sure with more time I could always get better results but I find esp when editing lots of photos this approach is enough….

That is precisely what I don’t know, and why I keep asking IF my suggestion could work. The mask’s dynamic range is the one that actually shrinks, not the final image, and we need 9 distinct lightness values for our nodes, which will get interpolated to create a curve. Since the goal of the mask is to blur things of similar brightness value and respect edges, I believe it could work.

Also, it seems the contrast slider has an effect on the guided filter, and actually alters what is blurred, and how things are blurred. However all of this is above my paygrade.

the working range of the moule is the range of the image thats covered by the mask. The EV range of the image can be far wider than 8EV since we are in scene referred part of the pipeline (current sensors can capture a range up to 14.8 EV)
So you need to decide, which part of the image range is covered with your mask.
Don’t bother too much on the histogram of the mask - masks are just tools. Better try set the mask just to differenciate what yo want to tweak in a different way.
And then move your mouse over the image and change what you need to change.

Of course. But to be able to use the mask you need to stretch it so that it spans several nodes.

Yes, that’s clear.

That’s also understood. I use the module, and can get results with it that I am happy with. My thoughts and comments regarding a zoomable interface are only aimed at improving a tool that already works well, but which in my opinion can still improve in terms of ease of use.

The problem with what you are suggesting is that, if your mask spans for example 2EV, and you only want to control the highlights with let’s say 6 nodes (spanning 5EV) you need to increase contrast compensation a lot. As a byproduct of that, you may get artifacts. With a zoomable interface, hopefully those could be avoided.

Are you sure that the artifacts are due to the contrast compensation in itself? If your mask covers a narrow tonal range, you can get unnatural effects because your correction causes a gradient inversion wrt the regions in the black or white zones of your mask (similar to what you can get using a parametric mask with e.g. exposure: select the sky, lower exposure a lot, and you get artifacts…)

No, I’m not sure. But here is a github issue from september regarding this:

And as I read that github issue, it was closed by the original author with no code changes…
Read the last reply by @anon41087856 in that issue, please.

Actually, that was brought up already in post 113. We’re going to go in circles here until someone programs a test version. Who has the time, ability, and motivation, I don’t know.

1 Like

Oops, my bad. It was me who brought it up! Mea culpa