Translating
const float chroma_boost = d->chroma_global + scalar_product(opacities, chroma);
const float vibrance = d->vibrance * (1.0f - powf(Ych[1], fabsf(d->vibrance)));
const float chroma_factor = fmaxf(1.f + chroma_boost + vibrance, 0.f);
Ych[1] *= chroma_factor;
into maths:
c_{in} = \sqrt{(r_{in} - r_{white})^2 + (g_{in} - g_{white})^2} \in [0; 1]
c_{boost} = v * (1 - c_{in}^{|v|})
c_{out} = c_{in} * (1 + c_{boost})
so c_{out} = c_{in} * \left(1 + v * \left(1 - c_{in}^{|v|}\right)\right) with v \in [-1; 1]
By design, Yrg is a normalized chromaticity space with
\begin{cases}
r = \frac{R}{R + G + B} \leq 1 \\
g = \frac{G}{R + G + B} \leq 1 \\
b = \frac{B}{R + G + B} = 1 - r - g \leq 1 \\
Y = \alpha R + \beta G + \gamma B, \{\alpha, \beta, \gamma\} \in [0; 1]
\end{cases}
So, by design, the chromaticity space is a triangular domain bounded by r = 0, g = 0, r + g = 1 over the (r, g) plane.
\{R, G, B\} \geq 0 are defined scene-referred from CIE LMS 2006 retina cone space by a matrix product such that Munsell hues are evenly spaced around the white point, so \begin{bmatrix}R\\G\\B\end{bmatrix} = [A] × \begin{bmatrix}L\\M\\S\end{bmatrix} where [A] is the 3×3 matrix that optimizes the hue linearity and even distribution of Munsell patches in Yrg space.
Going back to our vibrance transform:
- If v = 0, then c_{out} = c_{in}, so we have a no-op.
- If v = 1, then c_{out} = 2 c_{in} - c_{in}^2, so:
\begin{cases}
c_{out} > c_{in}, &\forall c_{in} \in ]0; 1[\\
c_{out} = 0, & \forall c_{in} = 0 \\
c_{out} = 1, & \forall c_{in} = 1
\end{cases}
- If v = -1, then c_{out} = c_{in}^2, so:
\begin{cases}
c_{out} < c_{in}, & \forall c_{in} \in ]0; 1[\\
c_{out} = 0, & \forall c_{in} = 0 \\
c_{out} = 1, & \forall c_{in} = 1
\end{cases}
which were the design constraints of the transform. The transform has been tuned such that \forall v \in [-1; 1] it degrades smoothly and respects the same boundary conditions as when v = \{-1; 0; 1\}. But it’s entirey made-up by limits analysis to assert the desired behaviour of affecting low-chroma colors more than high chroma ones under the smoothness and boundary constraints.
EDIT: @paperdigits @patdavid LaTeX support is the best thing that ever happened to this forum.