darktable-org / darktable

darktable is an open source photography workflow application and raw developer
https://www.darktable.org
GNU General Public License v3.0
9.51k stars 1.12k forks source link

Remaining ColorEq issues #16342

Closed s7habo closed 4 months ago

s7habo commented 6 months ago

Describe the bug

I don't know if it's because of the recent changes in the module, or I've found a specific example, but the brightness again seems to be very much dependent on the saturation.

In this example I want to darken the green:

grafik

If I do this with the guided filter turned on, I get this result:

grafik

Note that a very large area was simply not taken into account. It is not much better if you switch off the guided filter:

grafik

The mask also clearly shows that saturation (and brightness?) oriented selection:

grafik

The result looks much better if you correct the saturation beforehand with the color balance RGB module. Note that I have adjusted the saturation here so that I have saturated the highlights the most, the midtones much less and I even had to reduce the saturation for shadows. Then you get the result as I would expect:

grafik

In this way, the result comes pretty close to the result if you mask the green with the exposure module and darken it:

grafik

EDIT: Just as a thought, could it be that the brightness function depends on the saturation (purity) and on the original brightness of the area? This means that not only the saturated areas, but also the darker areas are affected much more than the brighter ones?

Steps to reproduce

  1. Lighten or darken a color range with different saturation/brightness in color equalizer. Depending on the saturation/brightness, the range is lightened/darkened differently, depending on the original brightness and/or saturation. The darker and more saturated areas are affected more than lighter and less saturated areas.

Expected behavior

The affected area should be lightened/darkened evenly regardless of the original brightness/saturation of the area.

Logfile | Screenshot | Screencast

No response

Commit

No response

Where did you obtain darktable from?

self compiled

darktable version

4.7.0+611~g76e4f8a6c

What OS are you using?

Linux

What is the version of your OS?

Ubuntu Studio 22.04

Describe your system?

KDE Plasma Version: 5.24.7 KDE Frameworks Version: 5.92.0 Qt Version: 5.15.3 Kernel Version: 5.19.0-1028-lowlatency (64-bit) Graphics Platform: X11 Processors: 8 × Intel® Core™ i7-7700K CPU @ 4.20GHz Memory: 31.3 GiB of RAM

Are you using OpenCL GPU in darktable?

Yes

If yes, what is the GPU card and driver?

Graphics Processor: NVIDIA GeForce GTX 1070/PCIe/SSE2 Driver: 535.154.05

Please provide additional context if applicable. You can attach files too, but might need to rename to .txt or .zip

No response

jenshannoschwalm commented 6 months ago

I guess you are aware of the analyse radius button? You will have false colors for parts that can be changed in bright read and that wont be changed in dark blue ...

The color maths including the guided filter have not changed for "some time" - still looking for examples where it fails as in this image...

s7habo commented 6 months ago

I guess you are aware of the analyse radius button? You will have false colors for parts that can be changed in bright read and that wont be changed in dark blue ...

Yes, I am aware of that. For the example above, it looks like this:

grafik

Moving the slider does not cause any change and has no effect on the result, regardless of whether the guided filter is switched on or off.

jenshannoschwalm commented 6 months ago

Moving the slider does not cause any change and has no effect on the result, regardless of whether the guided filter is switched on or off.

Right. Right now it just displays the weighing mask. We still have not found a "perfect" solution as we clearly see here, often in the green tones ...

s7habo commented 6 months ago

It works well for saturation. However, there is a big difference between switching the guided filter on and off.

GF off:

grafik

GF on:

grafik

s7habo commented 6 months ago

By the way, the raw file above is from https://www.signatureedits.com/free-raw-photos/

Simply scroll down until it appears or enter "DSC02363" in the search field and then it will be selected and can be downloaded

grafik

SoupyGit commented 6 months ago

Yes while recent changes improved the result a lot it is still not perfect, with light colours and in particular green.

Saturation: saturation

Brightness: brightness

jenshannoschwalm commented 6 months ago

@s7habo i certainly have the described problem "on radar".

Atm we have

  1. dark areas being favoured over bright parts regarding "guided correction". (The earlier issue was "dark areas not corrected :-) The reason for that is known - not sure yet how to handle that "the best way"
  2. greens being more problematic than other hues. That issue is still not understood.

I would love to collect all known issues with this module before starting a new iteration of work on module maths. Are you - or is anybody else - aware of other issues?

s7habo commented 6 months ago

Are you - or is anybody else - aware of other issues?

Yes, there is one that immediately comes to mind.

With smooth transitions, guided filter with brightness and saturation function produces banding:

With GF:

grafik

Without GF:

grafik

Hue function works correctly:

grafik

I am currently testing the module in more detail. If I notice anything, I'll let you know straight away.

jenshannoschwalm commented 6 months ago

Hi, #16363 will fix most issues as far as I can oversee it - tested on many images you provided and others. Let's keep track of problems here after that gets merged. It should work much better for all colorful areas, dark and bright.

jenshannoschwalm commented 6 months ago

Beside whatever issues you'll report, I am working on suppression of halos and increased chroma noise.

s7habo commented 6 months ago

Weighing function is now super!

grafik

The problems with bending are also gone. :clap: :+1:

The only thing that is still weak is the problem with green:

grafik

But what works very well now is the analysis radius and the guided filter. :rocket:

s7habo commented 6 months ago

I have now tried a lot of photos, and now I'm not sure if it's because of green.

When I compare the masks between the saturation and brightness functions, two things stand out:

  1. brightness is much weaker than saturation.
  2. saturation seemed to work more linear (flatter) and brightness logarithmic (more contrasty)

Here are a few examples for comparison.

grafik

Saturation mask:

grafik

Brightness mask:

grafik

Org:

grafik

Saturation mask:

grafik

grafik

Org:

grafik

Saturation mask:

grafik

Brightness mask: grafik

jenshannoschwalm commented 6 months ago

I would like to emphasize, the 'mask" you see is not a mask, it's the result of what the module has been doing.

About the stronger effect on brightness, that could be changed without problems. There are some remaining halos and minor problems with chroma noise, I would like to sort that out before extending brightness correction range.

s7habo commented 6 months ago

In any case, thank you very much for your efforts!

Once this little rest of the problems are cleaned up, this will be a new milestone in image processing with darktable.

SoupyGit commented 6 months ago

Saturation is now perfect!

saturation

And brightness has improved:

brightness

now I'm not sure if it's because of green.

Yes it seems to me now that lightness is the main determining factor. The colours that go to black quickest are those that appear darkest to begin with (red > blue). Of course I am of no help in determining the cause. Great work again @jenshannoschwalm!

jenshannoschwalm commented 6 months ago

@s7habo i have renamed the title of this issue to keep attention on this, ok?

@s7habo @SoupyGit i think i don't get "what exactly is the brightness issue" :-)

The module works in UC22-HSB space so the brightness - and also it's correction - is not linear, the visualizing mask shows changes in linear space though. Do you/we want more range for brightness correction? Or elaborate please ...

s7habo commented 6 months ago

i have renamed the title of this issue to keep attention on this, ok?

Yes, thanks!

Or elaborate please ...

Brightness function seems to follow a kind of "s" curve. This means that in an area with the same color but different brightness, the contrast is increased.

To illustrate, the brightness function follows...

grafik

... a curve like this:

grafik

If this were a linear function, you would have something like this:

grafik

And that's what you would have expected as a user.

And because that's not the case...

Do you/we want more range for brightness correction?

...the answer is definitely yes, but how much depends on how/if this relates to increasing the contrast.

jenshannoschwalm commented 6 months ago

Aah, got it. Indeed the brightness correction follows the s-shaped weighing curve in a slightly different way atm, you need more saturation to have any change in brightness. Knowing that and working on it.

s7habo commented 6 months ago

Indeed the brightness correction follows the s-shaped weighing curve in a slightly different way atm, you need more saturation to have any change in brightness. Knowing that and working on it.

By the way, what just came to my mind, if you are already working on the solution, this kind of contrast that we now have as a "problem" could be very useful in some situations. How would it be - if it turns out to be possible in your investigation - to control this dynamically?

Like a kind of additional slider for brightness function with which you can go from "brightness with strong dependence on saturation" to "brightness with low dependence on saturation", with which the contrast becomes stronger or weaker accordingly?

Just as an idea. :grinning:

jenshannoschwalm commented 6 months ago

Yes that could be done. I take your word about usability VS user interface here. So make up your mind, yes or no :-)

s7habo commented 6 months ago

So make up your mind, yes or no :-)

I say yes and am immediately on the hunt for a good example. :point_up:

s7habo commented 6 months ago

Here is one:

Before:

grafik

After:

grafik

Visualization:

grafik

And now I know why I thought of that. We had the discussion here about Fuji color chrome effect:

https://discuss.pixls.us/t/what-is-color-chrome-effect-and-how-to-achieve-it/18760/6?u=s7habo

Roughly speaking, this effect darkens the intense color areas to create an additional contrast that is lost with strong saturation.

s7habo commented 6 months ago

Here are two more examples:

Note how the texture of the leaves is enhanced here:

Before:

grafik

After:

grafik

Here the car gets nice contrasts:

Before:

grafik

After:

grafik

s7habo commented 6 months ago

I have one more idea that I would like to get rid of and then I'll stop because it belongs in the feature request section:

If you can have the same weight slider by saturation also for the saturation function itself (stronger saturation for already saturated colors vs. even saturation) you would also have what "vibrance" function does in color balance rgb module.

This would give both saturation and brightness functions an additional - let's call it - "vibrance" slider. I can imagine a lot of possible uses for this. But we can talk about that later.

s7habo commented 6 months ago

Excellent work @jenshannoschwalm ! With your latest contribution, the color equalizer is slowly becoming the Swiss army knife for dealing with colors. :)

Here's an example right away:

In this photo...

grafik

...we wanted to darken the skin. With a very low effect radius, however, the skin looks very rough:

grafik

To counter this, we now increase the effect radius. The skin now looks nice, but the fur on the hat has lost its local contrast:

grafik

If we now also increase saturation threshold to increase saturation restriction, the fur of the cap regains its local contrast because it is excluded from the darkening. Face has more contrast and the neck is cleanly separated from the environment, which also prevents haloing of guided filter. This is really a very nice additional control:

grafik

The new saturation threshold function is a huge improvement in my opinion!

I have two questions in this regard.

  1. The slider is limited to -/+ 10% Can the radius of action be increased to -/+30% or more? Or one leave it as it is, but offer the possibility to enter higher (or lower) values via keyboard if necessary.
  2. The transitions between saturated and non-saturated areas are a bit harsh. Could this also be controlled somehow with the guided filter?
TurboGit commented 6 months ago

The new saturation threshold function is a huge improvement in my opinion!

In this specific example I suppose that one could have been used a parametric mask on saturation.

s7habo commented 6 months ago

In this specific example I suppose that one could have been used a parametric mask on saturation.

Unfortunately not. That was the first thing I tried to compare. This is the best I could achieve with the parametric mask based on saturation:

grafik

If you want to exclude the fur, you lose the area around the neck:

grafik

And this is what the visualization of the saturation threshold in color equalizer looks like (red is what is affected):

grafik

And this is the visualization of the effect radius. This gives the result a natural contrast:

grafik

Of course, you could also achieve this with additional masking. But if you have immediate control with a slider, that's actually great.

But I have to test it more intensively to see how it behaves with other examples.

jenshannoschwalm commented 6 months ago

I have two questions in this regard.

1. The slider is limited to -/+ 10% Can the radius of action be increased to -/+30% or more? Or one leave it as it is, but offer the possibility to enter higher (or lower) values via keyboard if necessary.

2. The transitions between saturated and non-saturated areas are a bit harsh. Could this also be controlled somehow with the guided filter?

Ad 1. Yes, although the percent value is not technically correct. With current code we can set the saturation threshold to values between 0 and ~25% (at 0 we have the default) I just thought this range would be sufficient :-) Let me know after further testing if this should be expanded, i wouldn't expect any problems from changing this.

Ad 2. Principally yes. The current weighing function is pretty steep around the threshold giving a good on/off effect. We could do that smoother of course but we reduce control of "colors should not bleed into achromatic areas" which was pretty bad in the original code. That would require an additional slider again ... something i would not like too much.

So, yes - both things could be done without big problems. As you compile yourself you might try this:

Ad 1: See line 102, change this to

  float threshold;          // $MIN: -0.1 $MAX: 0.2 $DEFAULT: 0.0 $DESCRIPTION: "saturation threshold"

Ad 2: Line 356, change the -60.0 to -30.0 for a smoother transition.

    satweights[i+SATSIZE] = (float)(1.0 / (1.0 + exp(-60.0 * val)));
s7habo commented 6 months ago

So, yes - both things could be done without big problems. As you compile yourself you might try this:

Unfortunately, I'm not that good. I only compile master version according to idiot-proof instructions for Ubuntu which I just blindly follow. :)

As for the first point, I'm already pretty sure that the range can be extended.

As for the second point, if it requires a new slider, I will also say that we don't need to overdo it. It makes sense to wait and see.

s7habo commented 6 months ago

And now, after the https://github.com/darktable-org/darktable/pull/16415 :

"Barbie doll" (saturation threshold -10%) vs. natural saturation gradient in the face (saturation threshold + 18%):

grafik

Uniform (saturation threshold -10%) vs. "Kodachrome 64" saturation distribution (saturation threshold + 18%):

grafik

I can well imagine that analog film fanatics will now be very happy and a lot of presets will be circulating in the forums when the new darktable version comes out. :)

And for me it's now time for extensive testing.

Thank you @jenshannoschwalm !

jenshannoschwalm commented 6 months ago

And for me it's now time for extensive testing.

Waiting for feedback :-)

TurboGit commented 6 months ago

@s7habo :

I can well imagine that analog film fanatics will now be very happy and a lot of presets

Speaking of presets, if during your testing you have some nice (and generic) one to share do not hesitate, I'll be happy to integrate them.

s7habo commented 6 months ago

Speaking of presets, if during your testing you have some nice (and generic) one to share do not hesitate, I'll be happy to integrate them.

colorequal_Kodachrome 64 like .dtpreset.zip

The preset is made according to the "Kodachrome 64" LUT from the RawTherapee collection here:

http://rawtherapee.com/shared/HaldCLUT.zip

In the collection is also the generic version, but this version requires additionally the shift of the white point in highlights towards magenta, which is not possible with CE module.

The preset works best in combination with the "smooth" preset in sigmoid, but can also be used with filmic.

The overall saturation can be adjusted with the color balance rgb module if required. However, I recommend reducing the saturation in highlights as this allows you to achieve the natural saturation distribution that also occurs in LUT.

Here are a few examples (original on the left, "Kodachrome 64 like" preset on the right):

grafik

grafik

grafik

grafik

grafik

grafik

I will offer some other presets soon.

s7habo commented 6 months ago

colorequal_Kodak portra 400 like.dtpreset.zip

This preset is based on "Kodak Portra 400 UC1" from HaldCLUT collection and provides a nice color balance for most photos.

The subtle separation of cold and warm tones (shifting green and blue towards cyan and red and yellow towards orange) gives a good color contrast on the one hand and a nice color gradient for skin tones on the other.

This preset expects the saturation in general most in mid tones. Accordingly, the saturation in shadows and highlights should be reduced slightly with color balance rgb.

Here are a few examples (original on the left, "Kodak portra 400 like" preset on the right):

grafik

grafik

grafik

grafik

s7habo commented 6 months ago

Orange & Teal.dtpreset.zip

Very exploited but still very popular color style. You can use it like this or adjust its intensity with the opacity slider.

Here are a few examples (original on the left, Orange & Teal" preset on the right):

grafik

grafik

grafik

grafik

s7habo commented 6 months ago

bleach bypass.dtpreset.zip

A visual effect used primarily in the film industry in which the bleaching process is partially or completely skipped during color film processing.

A famous example is the film "Saving Private Ryan" by Spielberg.

The result is a de-saturated and high-contrast photo that is on the verge of black and white, which shifts the focus to the form without completely sacrificing the color:

grafik

grafik

grafik

Due to the fact that the colors are not very dominant, a very nice color mood can be achieved by additionally changing the global color tone with global offset in color balance rgb module:

grafik

s7habo commented 6 months ago

@jenshannoschwalm what i noticed is that saturation threshold goes from -10% to +20%. why not from -20% to +20%. If this also affects the de-saturated areas that could also be an advantage.

So, if there are no technical concerns, it would be interesting to know how the module behaves when the saturation threshold goes below -10%. :)

By the way, after working with the module for a while now, it works very well.

jenshannoschwalm commented 6 months ago

The range of -10% to 20% is fully sufficient as the saturation threshold is relative to default resulting in saturation inflection points between -0.05 to 0.6. (You can see the curve via the masking buttons as you know)

@s7habo @TurboGit: We might concider though: Currently we use a non-linear scale for threshold and could redefine the threshold slider

  1. to be in linear 0 to 60% range, this would result in maths changing so breaking current edits
  2. to be in non-linear 0 to 30% range, this could be done more easily without breaking edits
jenshannoschwalm commented 6 months ago

With today's master, is there still need for the guiding filter toggle on/off?

s7habo commented 6 months ago

With today's master, is there still need for the guiding filter toggle on/off?

I will suggest a few days of testing and then we can decide. I would like to try it out on some photos first.

In any case, the latest version is great! Good work @jenshannoschwalm ! And also many thanks for the quick integration into the master @TurboGit !

jenshannoschwalm commented 5 months ago

@TurboGit @s7habo again, do we still need the guiding toggle button?

TurboGit commented 5 months ago

@jenshannoschwalm : I need more time to have a definite answer, I don't have used it enough at this point. What I can say is that for now I have always activated the guiding filter.

s7habo commented 5 months ago

@jenshannoschwalm: I use color equalizer often and always turn it on and off to see the differences. With some photos there are indeed differences. These are usually the differences in the sharpness of the image when the guided filter is switched on. I would also like to play with it a little longer.

jenshannoschwalm commented 5 months ago

Okidoki

TurboGit commented 4 months ago

I'll close this at this time. We'll reopen separate issues if needed.