Previous Next


                                                523
SECTION 7.2                                                   Basic Compositing Computations



3. Convert the result back to the original (blending) color space.

However, the formulas given below do not actually perform these conversions.
Instead, they start with whichever color (backdrop or source) is providing the hue
for the result; then they adjust this color to have the proper saturation and lumi-
nosity.

The nonseparable blend mode formulas make use of several auxiliary functions.
These functions operate on colors that are assumed to have red, green, and blue
components. (Blending of CMYK color spaces requires special treatment, as de-
scribed below.)
Lum(C) = 0.3 × C red + 0.59 × C green + 0.11 × C blue

SetLum(C, l)
      let d = l – Lum(C)
      C red = C red + d
      C green = C green + d
      C blue = C blue + d
      returnClipColor(C)

ClipColor(C)
         let l = Lum(C)
         let n = min(C red, C green, C blue)
         let x = max(C red, C green, C blue)
         if n < 0.0
              C red = l + ( ( ( C red – l ) × l ) ⁄ ( l – n ) )
              C green = l + ( ( ( C green – l ) × l ) ⁄ ( l – n ) )
              C blue = l + ( ( ( C blue – l ) × l ) ⁄ ( l – n ) )
         if x > 1.0
              C red = l + ( ( ( C red – l ) × ( 1 – l ) ) ⁄ ( x – l ) )
              C green = l + ( ( ( C green – l ) × ( 1 – l ) ) ⁄ ( x – l ) )
              C blue = l + ( ( ( C blue – l ) × ( 1 – l ) ) ⁄ ( x – l ) )
         return C

Sat(C) = max(C red, C green, C blue) – min(C red, C green, C blue)

Previous Next