Where is the calculation code for color cast using hue and saturation in color balance?

I hope to learn the algorithm for color cast through hue, but I can’t find the location of the code.

The darktable source code is hosted on github. If you can read C, you could use this file with as a starting point for your search.

1 Like

thanks, I can read C.
I saw that darktable has two color balance functions. What I want to know about is the second one. Is this file the implementation of the first function?

In addition, I saw that there is a file called “colorbalance.c” in the same directory, but there are only some UI-related implementations.

Don’t forget to read the relevant parts of the manual to understand what the controls actually do.

And yes, it’s quite possible that the actual work is done elsewhere. Especially if that code is used multiple times. You’ll have to see what code is used by the code you are looking at (look at the "#define"s at the start of the file, and where that code is used (usually a place where colorbalancergb.h would be referenced). Pretty standard for (C) programs.

But frankly, I don’t really understand what you want to learn, “the algorithm forcolor cast through hue” is a bit vague.

In any case, studying source code will not teach you an algorithm, it will teach you one implementation of such an algoritm, with all the adaptations for the particular use case you study.

What I linked was the color balance rgb module which is scene-referred. The second one is the “old” display-referred module.

I was wondering if you might know where the code for the second module is located.

Here?

I am not a developer.

The are all in the src\iop folder on Github…DT pipeline has color gamut/luminance control in several places that can impact color calculation…even the rgb CB module can work in two color spaces UCS and JzBzCz I believe…the initial “color cast” of the image is handled in the color calibration module as part of “white balancing” so there are some expectations and interactions between certain modules…

1 Like