New Primaries module

ACR has a similar tool… this is a pretty good video with a couple of suggestions on how you might use it…

2 Likes

Yes, that would be a good reason. And it’s clear that @s7habo often reaches for the channel mixer as his first choice when colour grading and working on his colour harmonies. So, it obviously has its merits over other tools.

I myself use the channel mixer when I’m doing some colour correction work, but I’m not always sure why, if that makes sense. As a rule, you often need to offset changes you make in one slider by tweaking other sliders. If your sky is too purple, for example, you might remove red from the red channel using input blue, but then add a little red back using input red to stop the image from looking too cyan. There is often this back and forth between sliders and tabs to ensure the overall balance of the image is retained when shifting colours. While this works, it can be quite tricky and involves lots of slider fiddling and tab switching, when all we wanted to do was shift the blue to a more cyan colour.

I have barely started using the new primaries module, but I’m wondering if it will be similar in that we might need to be adjusting multiple sliders to offset unwanted colour shifts after adjusting the main colour shift we want. Of course, it becomes easy with practice, so this is not necessarily a big problem.

@s7habo, do you think you would use the primaries module and/or channel mixer as much as you do now if there was a scene-referred colour correction module (like the abandoned color EQ / color zones / color lookup table)? What do you consider are the unique benefits of the primaries module / channel mixer compared to these other modules?

(Thanks @priort, I will check out that video)

1 Like

Ya I think you will always be doing adjustments. One thing you see with the global change vs using hue or something that you can avoid a pixelated jpg that sometimes can happen in you push focused hue adjustment too hard… I think it really a tool to make smaller tweaks to work on skin tones color casts and overall image look.

Some other examples

This guy is a bit over the top but the video has other examples of how you might use it…

1 Like

Hi @europlatus! Thank you for the excellent questions. I feel others have already replied many of those (particularly related to use cases) and I’ll try to fill in regarding the theory.

There are two constraints that are enforced:

  1. The neutral (achromatic) pixels are left intact unless you want to change them (by using the tint sliders)
  2. The global exposure is left intact (one could also consider this as part of point 1)

These are sensible constraints to allow editing the colors without affecting the already-chosen white balance and exposure. A similar enforcement of the neutrals can be achieved with the color calibration module by ticking the “normalize” boxes in the R, G, B tabs.

This explanation requires basic knowledge of matrix math, but please bear with me. Each row of the 3x3 matrix corresponds to one tab of the color calibration tool. The channel mixing operation can be described by the product of such a matrix and the input RGB vector. Here a “no-op” identity matrix is shown - each of the output components gets the value of the corresponding input component.

\begin{pmatrix} R_{out} \\ G_{out} \\ B_{out} \end{pmatrix} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} R_{in} \\ G_{in} \\ B_{in} \end{pmatrix}

Now, as an example, consider you would like to switch the blues a little bit toward cyan. You could begin by adding an off-diagonal component to the green row:

\begin{pmatrix} 0 \\ 0.1 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0.1 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix}

We have successfully shifted the blue toward cyan by adding a green component to a value that originally had only a non-zero value in the blue channel. Also, at this point we can rest reasonably convinced that the red and green primaries remain as-is (do a similar calculation with those to verify). A fun exercise is to see if the opponent yellow and the adjacent cyan and magenta secondaries are changed (and how). Is this in line with the expectation you illustrated with the color circles image?

Let’s see if the neutrals are still intact:

\begin{pmatrix} 1 \\ 1.1 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0.1 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix}

Oh no! The white point has shifted! This has to be compensated somehow. One option is to change the element at (2, 2):

\begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 0.9 & 0.1 \\ 0 & 0 & 1 \end{pmatrix} \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix}

Phew, now the neutral axis is again where it should be, and blue stil gets shifted to cyan (0, 0.1, 1). Now, look at the resulting matrix and try to think, what happens when the other primaries or secondaries are multiplied by it? Are there some that are changed? Are some left intact? How does this differ from the result in the previous step? I won’t spoil the fun for you just yet to let you and others think through this. :slight_smile:

By completing the above calculations, one should be convinced that enforcing the neutrals defines the way how this new module works. Just a further hint for the “why”: if neutrals are to be left intact, one should always have (to give an example) that the sum of the blue primary and yellow secondary, both rolled through the multiplication, should be white. Now, if our blue if mapped through the module gives (0, 0.1, 1) as in the example above, how would we have to modify the yellow (1, 1, 0) to balance this out, to have the sum at (1, 1, 1)? This gives a hint of how the opponent colors work together.

Ok, enough of theory for now. Still, I want to emphasize that this is not a hue-selective color editing tool, but one for editing the global colorimetry. Of course one can also use masked instances of this one to achieve local effects. I haven’t tried this myself, but my gut says that due to the constraints discussed above, local usage of this module could also blend in pretty nicely.

As for potential use cases, there have been good examples already in this thread, including the various tutorial videos for Lightroom. My ideas of potential usages:

  1. Delicate corrections to e.g. skin tones, autumn leaves, sunsets… you name it. As it has been showcased in various Play Raws in this forum, we seem to be particularly sensitive to the yellow-to-orange range being in the right place. This module should allow easy corrections to that if something feels off.
  2. Creative looks. To draw an analogy to film photography: photographic film emulsions have those photosensitive crystals that are coupled to dye particles. Now, each film stock might have some different combinations of the dye (which color is produced) and spectral response (which color excites those crystals). We certainly can not emulate all the complexity of the image formation in film, but channel mixing is a primitive way of establishing a sort of a “base look”.

Certain types of creative looks might be easier to create with the plain channel mixer (i.e. color calibration module). One example that comes to my mind is channel swap.

If you made it this far reading the post and did the math exercises, you should find the answer is yes. To change one of the secondaries, grab the hue slider of the opponent primary.

I’d say that rgb primaries can be used in combination with the modules you mentioned. First, establish a “base look” with rgb primaries that takes the image globally to the direction you like - then, use those more focused / selective tools for fine tuning. One example would be the darkening of the greens that is showcased here that can’t be easily achieved with this kind of a global tool.

The benefit of using rgb primaries for the base look? Practically no artefacts (due to the underlying linear operation) and maintaining a certain consistency that arises from keeping the neutrals intact (and also, opponent colors still remain opponents after the operation).

Very good questions. Please keep asking those important "why"s. Hope I managed to answer at least some of those.

Have a happy weekend everyone!

21 Likes

Thanks @flannelhead for a fantastic answer and explanation. Since originally asking those questions I had done more research and testing with RGB Primaries and the channel mixer, and I had come to the conclusion that the new module was equivalent to using the normalization checkbox in the channel mixer. And you confirmed that in your response above, which was great to read.

I’m looking forward to playing with the module more. What I particularly like about it is that all the sliders are on the same panel. There’s no switching between tabs, which helps to streamline workflow that bit more.

I still hope that Color EQ will one day be resurrected or an updated colour lookup table module for the scene-referred workflow will arrive. But in the meantime, this new module is another valuable tool for colour correction. Thanks for all your hard work!

1 Like

Well done and glad the response was also helpful.

This was one of the reasons to implement this as a new module instead of just an alternative interface to color calibration. The other thing that makes this module very convenient is that it’s more obvious from the interface, which slider should you drag to take one primary to a particular direction.

5 Likes

@s7habo
Boris, in one of your videos (and later in a posting here in the forum) you presented a very useful (thanks!) audio-system metaphor for beginners in how to understand the interplay between central processing modules for scene referred in DT.
(Exposure and Color Calibration as basic global controls for brightness and color grading respectively, with Tone Equalizer and Color Balance RGB for further fine-tuning of the same, and then with Filmic RGB (and now Sigmoid) as a border control to keep output values within black white / gamut.)

How du you think the new RGB Primaries could best be put into this metaphore?

One thing that has confused me by the presentation of the new RGB Primaries module (that I haven’t yet available), is the term “purity” on the label of sliders.
This is a term I haven’t yet come across in DT documentation - it doesn’t come up in a search in the manual.

But I came across a note from this posting here in the forum:

which I believe is AP’s, where he stated in January 2021 that:
“I learned recently that purity is actually called brilliance since the 1950’s”

Is there a reason to introduce a new / too old term, if it really ought to be in constancy with “brilliance” now used in the other scene referred color modules?
Should we clean this up before the module is officially launched in DT 4.4?

Perhaps Sakari has some views on this? @flannelhead

3 Likes

I believe brilliance and purity are two different but related things. I have a bad memory, so I cannot say more than that. I would have to reexamine the literature and math. Also be careful: people can use the same terms differently, even scientists and engineers. The only way to be sure is to check the implementation, but that is not for everyone.

Hint: dt modules usually come with descriptions on hover for the module itself and its parameters. Maybe the information is already there.

1 Like

I don’t think its brilliance either… brilliance is the appearance of brightness wrt to surrounding elements… purity is more of a chroma/saturation thing… basically the primaries module is allowing you to define what hue is red what is blue and what is green… and by association what then happens to the rest of the hues in the image when one of these is changed… purity slider brings the coordinates in/out and hue slider rotates them…

You are simply able to tweak the main points on the currently chosen colorspace to make global or masked changes… at least that is how I understand it…

Pretty easy to see if you just watch the vectorscope…

Defined here

You are being redirected....

EDIT

Visual here…

The module has two constraints so as not to impact global exposure and on neutrals so as not to mess up white balance

4 Likes

In terms of colors, primaries module is on the same level as color calibration (global adjustment). It has the same task as channel mixer with the difference of simpler handling.

We wait what @flannelhead says about it, but I think the @priort is right. Purity affects/means saturation - relative distance of color from white point:

6 Likes

I think the term purity also is a sort of reference to the straight line from the white point out to the perfect monochromatic spectrum for that dominant color ie full saturation. Then any point in between white and the 100% monochromatic boundary is assigned a purity based on the distance between white and 100%. So the hue slider is going to move that location on the boundary and the purity will put it somewhere on a line between there and white… I added a nice visual in the edit to my post above…

1 Like

Yes, that’s exactly what the graph I linked above shows.

1 Like

There was already some discussion about changing the term to ”saturation”: Update primaries.c with more explaining tooltips by MStraeten · Pull Request #15218 · darktable-org/darktable · GitHub

I’ll try to do that and a couple of other little improvements before the freeze

11 Likes

Quite interesting that my Pentax camera puts into metadata something very similar to primaries coordinates:

$❯ exiftool 20231016_0021.PEF | grep -i matrix
Color Matrix A2                 : 5857 2334 0 0 8192 0 0 335 7856
Color Matrix B2                 : 13952 -4416 -1344 -1472 13792 -4128 128 -2816 10880

I only doubt they can be somehow decoded without reverse engineering of proprietary s/w…

1 Like

Interesting discovery. Curious what could be done with those. They seem to be Pentax-specific, as the only Google hits with those keywords returned Pentax-related results. Perhaps one could just try and see if they are close to the matrices that are in e.g. RawSpeed’s data for that camera.

1 Like

I posted a couple of enhancements to the module for review. This includes change of tooltips and backgrounds of the purity sliders. Now, the module should be good to go for the next release.

I also initially considered changing the term purity to saturation, but decided to keep it in the end. The reason is that purity is an exact term for the technical adjustment that the module is doing. Saturation, on the other hand, is a perceptual quality of color, and this module doesn’t do perceptual saturation adjustments.

Is there a reason to introduce a new / too old term, if it really ought to be in constancy with “brilliance” now used in the other scene referred color modules?

I believe this is a mix-up - as far as I see it, purity and brilliance are nowhere near congruent.

It might be worthwhile to add the term purity to the documentation, though. I’ll try my best to find the time to write a piece of documentation for this module, and description of purity could naturally fit in the module documentation.

11 Likes

Is this module already in the git master version for debian that is available via obs? I can’t find it under the module name “primaries”.

It’s called rgb primaries, and it’s on master. I don’t know if it (or the previous version, without the most recent enhancements) is part of the OBS build.

1 Like

Can you make use of the appimage from here??

2 Likes