Color and Tonal Adjustments
|
This article is addressed to advanced users. It describes the internal calculations for color and tonal adjustment filters.
General
To adjust colors, brightness and contrast of a pixel image, use the settings in the Graphic panel in the properties deck of the sidebar.
These settings are written to the file, but the image itself is not altered. Therefore, you can use these filters not only for embedded images, but for linked ones as well.
The colors are defined in an 8-bit RGB color space. The color of a pixel is a vector with a red, green and blue component, each with integer values in the interval [0‥255].
A filter can be described by a function. Input parameter is the original color or the output of another filter. The resulting output is the rendered color or the input to another filter. You can illustrate the relationship between input color and output color by a function graph in a coordinate system with the input color on the x-axis and the output color on the y-axis.
If a filter is not applied, the function graph is a straight line in 45 degree to the x-axis.
Contrast
The contrast is a signed percent value in the interval [−100%‥100%]. A positive value increases the contrast of the rendered image, a negative value decreases the contrast. This filter is applied to all color channels at the same time.
The filter function is linear. Its slope is calculated by
getting the slope for a positive contrast adjustment value
getting the slope for a negative contrast adjustment value
The value 128 is not affected by this filter. So the resulting function has the term
Luminance
The luminance is a signed percent value in the interval[−100%‥100%]. A positive value increases the brightness of the rendered image, a negative value decreases the brightness. It is applied to all color channels at the same time. The function graph is simply shifted up or down.
.
Color Adjustment
The color adjustment is similar to the luminance, but for each color channel it has a separate value. A positive value increases the intensity of the color, a negative value decreases it. The color adjustment can be used for a white balance of the rendered image.
Resulting Filter
Color adjustment, contrast, and luminance settings are applied at the same time.
Let blueIn be the blue component of a pixel in the original image, then the blue component of the rendered pixel can be calculated as below. The green and red components are calculated analogous.
The rendered color blueOut is rounded to integer and constrained to the interval [0‥255].
This filter is not applied to an alpha-channel, which might be present.
The adjustments here are applied before changes, which are induced by the gamma value.
Gamma
The gamma filter provides a non-linear filter, which mainly affects the contrast of the mid-tones. It can be used for a manually gamma correction for special output devices or environments. This filter is applied to all color channels at the same time.
The value gamma is a floating point number. It is stored in the file as percent, e.g. the value 2.5 in the UI is stored as 250%. The UI constrains the value to 0.1 ≤ gamma ≤ 10. Internally values outside the interval ]0‥10] are forced to 1.
Let blueIn be the blue component of a pixel in the image after applied filter for colors, luminance and contrast as described above. Then the blue component of the rendered pixel can be calculated as below. The green and red components are calculated analogous.
Because 0InverseGamma=0 and 1InverseGamma=1, are very dark colors, very bright colors are less affected than mid-tones.
Gamma = 0.5 | |
Gamma = 1 | |
Gamma = 2 |
This filter is not applied to an alpha-channel, which might be present.