Cielab Color Space
Total Page:16
File Type:pdf, Size:1020Kb
Gernot Hoffmann CIELab Color Space Contents . Introduction 2 2. Formulas 4 3. Primaries and Matrices 0 4. Gamut Restrictions and Tests 5. Inverse Gamma Correction 2 6. CIE L*=50 3 7. NTSC L*=50 4 8. sRGB L*=/0/.../90/99 5 9. AdobeRGB L*=0/.../90 26 0. ProPhotoRGB L*=0/.../90 35 . 3D Views 44 2. Linear and Standard Nonlinear CIELab 47 3. Human Gamut in CIELab 48 4. Low Chromaticity 49 5. sRGB L*=50 with RGB Numbers 50 6. PostScript Kernels 5 7. Mapping CIELab to xyY 56 8. Number of Different Colors 59 9. HLS-Hue for sRGB in CIELab 60 20. References 62 1.1 Introduction CIE XYZ is an absolute color space (not device dependent). Each visible color has non-negative coordinates X,Y,Z. CIE xyY, the horseshoe diagram as shown below, is a perspective projection of XYZ coordinates onto a plane xy. The luminance is missing. CIELab is a nonlinear transformation of XYZ into coordinates L*,a*,b*. The gamut for any RGB color system is a triangle in the CIE xyY chromaticity diagram, here shown for the CIE primaries, the NTSC primaries, the Rec.709 primaries (which are also valid for sRGB and therefore for many PC monitors) and the non-physical working space ProPhotoRGB. The white points are individually defined for the color spaces. The CIELab color space was intended for equal perceptual differences for equal chan- ges in the coordinates L*,a* and b*. Color differences deltaE are defined as Euclidian distances in CIELab. This document shows color charts in CIELab for several RGB color spaces. .0 y sRGB uses ITU-R BT.709 primaries 0.9 Red Green Blue White ProPhoto x 0.64 0.30 0.5 0.327 520 525 y 0.33 0.60 0.06 0.3290 0.8 55 530 535 AdobeRGB uses Red and Blue like 50 540 sRGB and Green like NTSC 545 CIE-RGB are the primaries for color 0.7 550 matching tests: 700/546./435.8nm 505 555 560 0.6 565 570 500 575 NTSC CIE sRGB 0.5 580 585 590 495 0.4 595 600 605 60 0.3 620 490 635 700 Wavelengths in nm 0.2 485 480 Purple line 0. 475 470 460 0.0 380 0.0 0. 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 x .0 2 1.2 Introduction CIELab uses new coordinates L*,a* and b* by functions as described in the next chap- ter. The true shape of the human gamut in CIELab is shown in chapter 13. This results in huge areas for higher luminance. Just to show the orientation together with the gamut triangle for the primaries we pro- ceed as follows: Convert the contour points x,y for Y= into RGB. Divide R,G,B by the maximum of R,G,B. Convert R,G,B to L*,a*,b*. The gamut triangle in xyY has to be replaced by a representation of a color cube with corners R,G,B and Y(yellow),C,M. The gray axis is at a*=b*=0. Therefore the area is confined by a distorted hexagon. A similar diagram can be found in []. Later it will be shown that the actual gamut, which depends on the luminance, is a smaller area inside the hexagon. -250 -225 -200 -75 -50 -25 -00 -75 -50 -25 0 25 50 75 00 25 50 75 200 225 250 b* 250 225 225 200 200 75 75 Green 50 50 25 25 00 00 Red 75 75 50 50 25 25 0 0 -25 -25 -50 -50 -75 -75 -00 Gamut -00 -25 CIE primaries -25 WP Eq.Energy -50 -50 Blue -75 Contour for -75 R-Y-G-C-B-M-R -200 hexagon -200 Outer blue area -225 -225 human gamut -250 -250 -250 -225 -200 -75 -50 -25 -00 -75 -50 -25 0 25 50 75 00 25 50 75 200 225 a* 3 2.1 Formulas / From RGB’ to CIELab R´G´B´ are nonlinearly distorted values for each channel in physical tristimulus systems like CIE, NTSC or working spaces like sRGB or AdobeRGB(98). RGB are undistorted values which are linearly related to CIEXYZ. Each RGB system has a white point(w). The transformation to CIELab requires a re- ference white point (n) which is either (w) or D50. Issues of adaptation are taken into account by the linearized Bradford transform. The Bradford matrix maps the XYZ-values for a color in e.g. D65 to another set in D50. The colors should look alike under D65 for the first set and under D50 for the second. Generic gamma correction, G=2.2, C=R,G,B CC= 'G sRGB gamma correction, C=R,G,B C'/2.92 if C'≤ 0.03928 C = 2.4 ((0.055+ C')/.055) else RGB to XYZ (same white point D65) XCR= xr RGB to XYZ (new white point D50, Bradford correction) XBCR= xr XYZ to L*a*b* (reference white Xn ) X X = Xn Y Y = Yn Z Z = Zn 3 X if X > 0.008856 X = 7.787 X+ 6 6 else 3 Y if Y > 0.008856 Y = 7.787 Y+ 6 6 else 3 Z if Z > 0.008856 Z = 7.787Z+ 66 else L*= 6 Y − 6 a*= 500 ( X − Y ) b*= 200 ( Y − Z ) 4 2.2 Formulas / From CIELab to RGB’ Please refer to explanations on the previous page. A value RGB is out of gamut if any of the numbers is less than 0 or greater than 1 (normalized values). L*a*b* to XYZ Y = (L* + 6)/6 X = a* / 500 + Y Z = − b*/ 200 + Y 3 X if X > 0.206893 X = (X − 6 6) / 7.787 else 3 Y if Y > 0.206893 Y = (Y − 6 6) / 7.787 else 3 Z if Z > 0.206893 Z = (Z − 6 6) / 7.787 else XXX= n YYY= n Z = ZZn XYZ to RGB (same white point D50) − RCXCX=rx = xr XYZ to RGB (new white point D65, Bradford correction) − − RBCXCBX= ()xr = rx Generic gamma correction, G = 2.2, C = R,G,B CC' = / G sRGB gamma correction, C= R,G,B 2.92C if C≤ 0.00304 C' = 2.4 .055C− 0.055 else 5 2.3 Formulas / From xyY to XYZ The CIE chromaticity diagram is called xyY.The threedimensional space is called XYZ. xyY to XYZ z= − x − y X= Y x / y Z= Y z / y XYZ to xyY DXYZ= + + x= X / D y= Y / D z= Z / D Some important numbers 3 0.008856= 0.2068930 6/6= 0.3793 6⋅ 0.008856 3 − 6 = 903.3 ⋅ 0.008856 = 8.0 6 2.4 Formulas / Structure of the Conversion The conversion from XYZ to L*a*b* consists essentially of four steps: . White point correction 2. Nonlinear distortion of the variables X,Y,Z by a cubic root 3. Linear transformation into a new vector basis c, a, b 4. Scaling With some obvious simplifications the linear part can be written by matrices: X 0 L Y = 0 0 A Z 0− B X 0 Y=LA0B0 + + = Lc + A a + B b Z 0 − L 0 0 X A = − 0 Y B 0 − Z Z c Y X,a b Base vector a points into X-direction, b into negative Z-direction and c is along the diagonal in XYZ. L, A and B are normalized substitutes for L*, a* and b*. 7 2.5 Formulas / Matrix Calculation Matrices for Primaries and White Point [3] XR YG = Cxr ZB RX GY = Crx BZ D= (xr − x)(y b g − y)(y b − r − y)(x b g − x) b U= (xw − x)(y b g − y)(y b − w − y)(x b g − x) b V= (xr − x)(y b w − y)(y b − r − y)(x b w − x) b u= U / D v= V / D w= − u − v ux/yr w vx/y g w wx/y b w C = uy/y vy/y wy/ y xr r w g w b w uz/yr w vz/y g w wz/y b w − CCrx= xr In the next formulas use cxrik for c ik D= c(cc 22 33− cc)c(cc 23 32 − 2 233− cc)c(cc 23 3 + 3 232− cc) 22 3 crx= ( c 22 c 33 − c 23 c 32 ) / D crx2= ( c 2 c 33 − c 3 c 32 ) / D crx3= ( c 2 c 23 − c 3 c 22 ) /D crx2= ( c 2 c 33 − c 23 c 3 ) / D crx22= ( c c 33 − c 3 c 3 ) / D crx23= ( c c 23 − c 3 c 2 ) / D crx3= ( c 2 c 32 − c 22 c 3 ) / D crx32= ( c c 32 − c 2 c 3 ) / D crx33= ( c c 22 − c 2 c 2 ) / D 8 2.6 Formulas / Bradford Matrix Calculation Bradford matrix calculation, based on [8] zn = − xn − y n Yn = Xn= Y n x n / y n Zn= Y n z n / y n zw = − xw − y w Yw = Xw= Y w x w / y w Zw= Y w z w / y w Cone response +0.895 + 0.2664 − 0.64 Mcx = −0.7502 + .735 + 0.0367 +0.0389 − 0.0685 + .0296 ρn Cn= γ n = MX cx n βn ρw Cw= γ w = M cx X w βw ρn/ ρ w 0 0 D = 0γn / γ w 0 0 0βn / β w Bradford matrix − BMDM= cx cx TheE.g.