René Krieg How to Convert a Bitmap to Polychromatic Light c 2008, LightTrans GmbH, Jena Copyright All rights reserved. René Krieg November 08, 2007 [email protected] Contents 1. The Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. False Color Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3. Real Color Import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 H O W T O C O N V E R T A B I T M A P T O P O LY C H R O M AT I C L I G H T 1. The Problem Since LightTrans VirtualLabTM represents light as electromagnetic field(s) of certain wavelength(s), considerations have to be made about an algorithm, able to transform a colored bitmap into polychromatic light. That means, a mapping has to be found for the three image channels R, G, and B, and three two-dimensional fields with three di=erent wavelengths. There are two di=erent ways to solve this problem, providing di=erent results. They could be named "Real Color Representation" and "False Color Representation" of the bitmap. While the latter keeps the portions of the three color channels R, G, and B by simply equalizing with the three wavelength channels only, the crucial constraint for the Real Color conversion is the identicalness of the light view of the field to the original bitmap. Both procedures will be described in the following and are outlined in the sketches below (Fig. 1 and Fig. 2). Figure 1. Algorithm for the false color import of bitmaps. An arbitrary wavelength is mapped to each of the channels R, G, and B, identifying the values of R, G, and B with the intensities of the fields. 3 H O W T O C O N V E R T A B I T M A P T O P O LY C H R O M AT I C L I G H T Figure 2. Algorithm for the real color import of bitmaps. The original color information is converted from the RGB color space to a previously defined color space, spanned by three appropriate wavelengths. For a detailed understanding of these considerations it’s essential to know the LightTrans Supplement "How to Bring Natural Light on a Monitor" ([NLOM]). It deals with the problem of displaying light of certain wavelength(s) on a computer monitor. 2. False Color Import A false color import can be used if the colors shall be alienated or if the colors do not have to be preserved. The algorithm simply uses the value R as intensity for wavelength λ1 , the value G for wavelength λ2 and B for λ3 . That’s it. 4 H O W T O C O N V E R T A B I T M A P T O P O LY C H R O M AT I C L I G H T 3. Real Color Import Essentially, the import of a bitmap that should be shown in real colors has to be the inversion of the wavelength-to-RGB algorithm described in [NLOM]. The reason is, that at first the colors given in the bitmap RGB color system ("source RGB") have to be transformed to a wavelength representation which can be handled in VirtualLabTM . The display routines will convert them to the display RGB color space ("destination RGB"). That means for the import to do a conversion from the source RGB to a new color space, defined by three wavelengths, which will be called "3L" color space in the following. The three constituting wavelengths λ1 , λ2 , and λ3 can be chosen relatively free, the only condition to be fulfilled is illustrated in Fig. 3: the triangle of displayable colors (called "gamut") spanned by the positions of the three wavelengths in the chromaticity diagram has to contain the gamuts of the used RGB spaces (usually: source = sRGB, destination = LightTrans Color System) completely. 0.9 y 515 0.8 520 525 530 535 540 510 545 0.7 550 555 505 560 0.6 565 570 500 0.4 0.3 0.2 575 3L 0.5 580 585 590 595 600 605 610 620 635 700 sRGB 495 490 485 480 0.1 0.0 0.0 475 470 460 380 0.1 0.2 0.3 0.4 0.5 0.6 0.7 x 0.8 Figure 3. Gamut of the VirtualLabTM 3L color space (continuous line) in relation to the standard RGB color space sRGB. For an explanation of the background of this diagram see [NLOM], please. Source: Gernot Ho=mann ( ∼ ), modified by LightTrans. 5 H O W T O C O N V E R T A B I T M A P T O P O LY C H R O M AT I C L I G H T For the particular case that the destination RGB color space is defined by three wavelengths λ R , λ G , λ B itself (i.e. if its primaries are pure colors on the spectral colors curve), the wavelengths of the 3L color space should be identical to them to avoid unnecessary out-of-gamut problems. This usually applies to LightTrans VirtualLabTM , since it’s default color system for the display is the ’LightTrans Color System’1 . So the three 3L wavelengths are identical to the spectral colors that define the LightTrans Color System as primaries: λ1 = λ R , λ2 = λ G , and λ3 = λ B . They and their chromaticities (according to the CIE31 measurement) are shown in the following table: λ(nm) 700 545 470 (x, y) (0.7347, 0.2653) (0.2658, 0.7243) (0.1241, 0.0578) The conversion of the ( R, G, B) triple of one bitmap pixel to the 3L color space will provide a triple of three weights (i1 , i2 , i3 ). These correspond to the intensity values at this position in the three twodimensional fields as the destination of the import. The correct display of this "monochromatic decomposition of polychromatic light" on the monitor will be done by VirtualLabTM ’s light view routines, as described in [NLOM]. The following algorithm is used to get the intensity triple for each pixel: 1. Rescaling and linearizing: ⎛ ⎞ ⎛ ⎞γ r R/255 ⎜ ⎟ ⎜ ⎟ ⎝ g⎠ = ⎝ G/255⎠ b B/255 2. Get the coordinates in the perceptional color space: ⎛ ⎞ ⎛ ⎞ r x ⎜ ⎟ ⎜ ⎟ ⎝ y ⎠ = TCIE · ⎝ g⎠ b z The conversion matrix TCIE is the inverse of the matrix described in [NLOM] that is used for the transformation from perceptional color space to RGB. 3. "Denormalizing", necessary to execute the inverse process of 1 Otherwise the following wavelengths are applied: (700 nm, 525 nm, 450 nm ) for ’Wide Gamut’ and ’Pro Photo’, (611 nm, 535 nm, 465 nm ) else. 6 H O W T O C O N V E R T A B I T M A P T O P O LY C H R O M AT I C L I G H T wavelength-to-RGB: ⎛ ⎞ ⎛ ⎞ x x ⎜ ⎟ ⎜ ⎟ ( x + y + z) ⎝y ⎠ = ⎝y⎠ · y z z 4. Get the intensities for the three wavelengths: ⎛ ⎞ ⎛ ⎞ x i1 ⎜ ⎟ ⎜ ⎟ ⎝i2 ⎠ = T3L · ⎝ y ⎠ , i3 z with ⎛ T3L X ( λ1 ) ⎜ = ⎝ Y ( λ1 ) Z ( λ1 ) X ( λ2 ) Y ( λ2 ) Z ( λ2 ) ⎞ −1 X ( λ3 ) ⎟ Y ( λ3 ) ⎠ . Z ( λ3 ) The functions X (λ), Y (λ), and Z (λ) are the Color Matching Functions, measured by the Commission Internationale de l’Éclairage (CIE), published in [CIE32], and cursory described in [NLOM]. 5. Handle out-of-gamut errors. If at least one of the calculated intensities is less than zero, an out-of-gamut error occurred. That means, the color of the pixel, according to the source RGB space, lies outside the gamut of the 3L color space. In this case, all intensities have to be shifted by subtracting the minimum value min(i1 , i2 , i3 ). To avoid this kind of error a priori, the wavelengths must be chosen in a way that the RGB triangle lies completely inside that of the 3L color space, see explanation above. As already mentioned, these steps has to be repeated for each pixel of the bitmap, resulting in three fields of the wavelengths λ1 , λ2 , and λ3 , filled with the intensity values i1 , i2 , and i3 . References [CIE32] Commission Internationale de l’Eclairage Proceedings, Cambridge University Press, Cambridge, 1932 [NLOM] How to Bring Natural Light on a Monitor, LightTrans Supplement, 2007. 7 H O W T O C O N V E R T A B I T M A P T O P O LY C H R O M AT I C L I G H T 8
© Copyright 2025 Paperzz