Vibrance¶
| Fact | Value |
|---|---|
| Also called | Smart saturation |
| Status | Implemented and tested |
| Family | Enhancement, illumination and color |
| Engine | Browser |
| Type | Nonlinear, color, saturation-weighted color mix |
| Output | Image |
| Operator shown as | color-transform (exact) |
| Support radius | 0 |
| Code | web/src/core/filters/enhancement/color-adjust.ts, vibranceFilter |
| Operator code | web/src/core/filters/enhancement/color-adjust.ts, vibranceFilter |
Overview¶
Vibrance raises the saturation of muted colors more than that of strong colors. Vivid colors, which would clip first, change little. The rule here is PixelNexus's own. Photo editors offer vibrance with the same aim, but do not publish their rules.
How it works¶
- Compute the HSV saturation S of the pixel.
- Set the factor to 1 + a (1 - S).
- Move each channel away from the gray by that factor, as in the saturation filter.
Mathematical foundation¶
The formula shows the default parameter values.
where
- \(S\): The HSV saturation of the pixel, from 0 to 1
- \(a\): The amount, from -1 to 1
- \(k\): The saturation factor for this pixel
- \(Y\): The gray value with the weights of the saturation filter
S is the HSV saturation of the pixel, 0 for gray and 1 for a pure color. Each channel C moves from the gray Y = 0.213 R + 0.715 G + 0.072 B by the factor k, as in the saturation filter. The factor shrinks as S grows. A muted color gets nearly the full factor 1 + a, and a pure color gets 1, so it does not change. This rule is PixelNexus's own. Photo editors offer vibrance controls with the same aim, but their rules are not published. The results are clipped to 0 to 255.
The factor falls in a straight line from 1 + a for a gray pixel to 1 for a pure color. So pure colors keep their values, and muted colors change the most. The gray uses the same weights as the saturation filter, so the gray value of each pixel stays until channels clip.
Kernel or operator¶
The Inspector shows the three steps: the saturation of the pixel, the factor, and the mix with the gray.
Algorithm¶
- Compute the HSV saturation S of the pixel.
- Compute the factor k = 1 + a (1 - S).
- Move each channel from the gray Y by the factor k.
Parameters¶
| Parameter | Default | Values | Meaning |
|---|---|---|---|
Vibrance vibrance |
50 | -100 to 100 % | The amount a, in percent. |
Implementation¶
vibranceFilter in web/src/core/filters/enhancement/color-adjust.ts. It is a pixel filter: the runner calls it once per pixel with the red, green and blue values, and rounds and clips the results at the end.
Worked example¶
| Input | Settings | Output | Pixel |
|---|---|---|---|
| (150, 130, 120) | 100 | (163.2, 127.2, 109.2) | (163, 127, 109) |
| (230, 40, 30) | 100 | (249.6, 34.8, 23.5) | (250, 35, 24) |
| (150, 130, 120) | -100 | (136.8, 132.8, 130.8) | (137, 133, 131) |
The muted color has saturation S = (150 - 120) / 150 = 0.2, so its factor is 1 + 1 x 0.8 = 1.8. The vivid red has S = 0.87, so its factor is only 1.13 and it barely changes.
Complexity¶
- Time: \(O(N)\)
- Memory: \(O(1)\)
N is the number of pixels. Each pixel takes a fixed number of operations.
Artifacts and limitations¶
Limitations
- Pure grays do not change, since they have no color to boost.
- The rule is PixelNexus's own, so the result differs from other programs.
Artifacts
- Muted noise can pick up color at high amounts.
Tests¶
The reference computes the same rule with NumPy on a small RGB test image with saturated, gray, black and white pixels. Each case compares all three channels.
References¶
- W3C. Filter Effects Module Level 1, section 13.1, the filter functions. W3C Working Draft, 18 December 2018. https://www.w3.org/TR/filter-effects-1/