Chapter 9. Color

RGB and Other Systems

Almost all modern color computer displays display colors by combining varying amount of red, green, and blue (RGB) light. These three colors stimulate the eye’s color receptors and approximate the sensation of viewing various colors; for example, orange light with a wavelength of about 600 nm cannot be produced by a com7puter screen, but emitting a modest amount of green light, a large amount of red light, and no blue light will provoke a sensation in the eyes of most viewers that will be indistinguishable from the sensation of viewing orange light. Color

Tip

Throughout X, color is spelled without a u, reflecting the American origins of the system. However, for those of us raised in Canada, the U.K., or any of the other commonwealth countries, that u is a hard habit to break, and it can lead to all sorts of mischief including syntax errors—so check your u at the door!

Since the perceived colors are created by the addition of three different wavelengths of light, this RGB color is considered to be an additive color system . The red, green, and blue colors used are called additive primaries .

Computer printers, on the other hand, use a subtractive colorsystem. The white paper reflects all visible wavelengths almost evenly; the dyes or pigments deposited on the paper absorb certain colors, effectively subtracting undesired wavelengths from the light reflected by the paper. The colors used ( subtractive primaries) are the complements of red, green, and blue: cyan, magenta, and yellow. To make it easier (and cheaper) to modulate the intensity of light, black is usually also used; since the color code for black is K, this color system is usually called CMYK (cyan, magenta, yellow, black).

Color spaces are the mathematical models that allow colors to be represented using a particular color system. For example, sRGB is a standardized RGB color space created in 1995 by HP and Microsoft and endorsed by many companies and organizations for use on consumer computer electronics such as monitors, digital cameras, and printers. The W3C has endorsed the sRGB standard for use on the Web. (http://www.w3.org/Graphics/Color/sRGB is referenced in specifications such as the HTML 4.01 at http://www.w3.org/TR/html4/.)

There are many other ways of describing color in addition to the RGB and CYMK schemes; the International Commission on Illumination,or Commission Internationale de l’Eclairage (CIE), is the international authority on these matters and has defined several very precise color spaces.

The range of colors that can be represented by a particular color space is called its gamut. Disparity between the gamuts of sRGB and CMYK color spaces is a source of continual frustration to graphic designers and computer artists, because printed images can never perfectly match screen images.

It’s important to keep in mind that we’re dealing with the perception of color, since there are few absolutes when dealing with the human eye. Consider a projection screen: when first unrolled, most people will tell you that the screen is white. But if you use a video projector to project a presentation slide with a few bright words onto the screen and ask the viewers what color the background is, those same people will tell you that the background is black, despite the fact that it is just as brightly lit as when they said it was white!

Visuals

When you use xdpyinfo to view the properties of an X server, you will see a number of visuals listed:

	number of visuals:     80
	default visual id:   0x21
	visual:
	  visual id:    0x21
	  class:    TrueColor
	  depth:    24 planes
	  available colormap entries:   256 per subfield
	  red, green, blue masks:   0xff0000, 0xff00, 0xff
	  significant bits in color specification:    8 bits
	visual:
	  visual id:   0x22
	  class:    DirectColor
	  depth:    24 planes
	  available colormap entries:   256 per subfield
	  red, green, blue masks: 0xff0000, 0xff00,   0xff
	  significant bits in color specification:   8 bits
	  ...Lines snipped...

These visuals are methods of managing pixel color on the display. There are seven types of visuals available, as shown in Table 9-1; the number after each visual class name is the visual class number used by the X protocol. The output from xdpyinfo shows the visual class along with information about the size of the color maps, the order of the RGB color information within the pixel color (controlled by the mask), and the size of each color component (significant bits).

Table 9-1. X visuals

Monochrome visual class

Color visual class

Colormap details

Typical number of panes

Notes

StaticGray (0)

StaticColor (2)

Nonwritable

1-16

GrayScale (1)

PseudoColor (3)

Writable

4-16

TrueColor (4)

Separate map for each RGB channel; nonwritable (linear ramp)

24

Most commonly used visual on modern displays

DirectColor (5)

Separate map for each RGB channel; writable

24

ARGB (6)

Same as True- Color

32

Alpha channel enables variable transparency; used with COMPOSITE extension

A colormap (or palette) is a numbered list of colors; a good analogy is that of a paint-by-number kit, where the number given for each area in the image is looked up in the colormap to determine the color to paint. In a similar way, the StaticColor and PseudoColor visuals interpret each pixel’s value in the video framebuffer as a color number which is looked up in the colormap; the color specified by the red, green, and blue values in the colormap is drawn on the screen. A StaticColor visual uses preset colors (such as the 16 VGA colors) while a PseudoColor visual allows the colors to be adjusted.

Changing a PseudoColor colormap entry will cause all pixels that are displayed in that color to immediately change. This feature is sometimes used by older games to produce fade-out and flashing effects.

TrueColor and DirectColor visuals store an actual RGB value in the video framebuffer. The individual red, green, and blue components are looked up in separate colormaps, or color lookup tables (CLUT), to determine the value of the signal to send to the monitor on the screen. TrueColor uses nonwritable colormaps to ensure linear intensity changes, while DirectColor uses a writable colormap to provide color-correction capabilities.

Most current desktop and notebook systems use a 24-bit RGB visual (DirectColor/TrueColor), but small-form-factor devices such as phones, PDAs, and tablets may use a more restrictive visual due to memory and power constraints.

When using 24-bit RGB values on a 32-bit system, multiple (sometimes partial) pixels occupy each memory word. This slows write speed by a factor of 75 to 90% and is so inefficient that many 24-bit systems actually devote 32 bits of framebuffer memory to each pixel; this wastes 8 bits per pixel (25% of the memory) but significantly speeds up write operations.

ARGB visuals use that extra 8 bits of data to represent transparency. This information is used by the COMPOSITE extension when building the screen image from the component images.

The default visual class—the class of the root window—is usually determined by the X server based on the number of bits per pixel, but it can be requested on the X server command line using the -cc option and a visual class number from Table 10-1:

	$ X -cc 3 -depth 24

In many cases, the X server will ignore the -cc option (or, as the Xserver manpage politely notes, this option is “Not obeyed by all servers”).

Tip

Your X sever may have an astounding number of Color True or DirectColor visuals defined; these are intended for use as OpenGL contexts.

Gamma

Cathode ray tubes, which were the first video output devices available and the earliest form of computer display monitor, have a nonlinear response to input. Output luminance is approximately equal to the input value (in the range 0–1) raised to a power of 2.2 (of course, the monitor’s brightness and contrast controls will also come into play, offsetting and amplifying this value). The exponent in this transfer function is called the gamma value.

Non-CRT monitors such as LCD panels, plasma displays, and projectors all process the input to produce roughly the same gamma curve as a CRT. In order to compensate for the this curve, video cameras are designed with a gamma of approximately 0.4; most digital images (such as those from digital cameras) are also adjusted to assume a nonlinear output curve.

sRGB assumes an effective monitor gamma of 2.2. If your monitor’s gamma value is incorrect, images will not be displayed as accurately as possible; gamma correction can be applied to the X server’s output to compensate.

The XFREE86-VIDMODE Extension enables the dynamic adjustment of the gamma correction settings. As the name implies, this is an extension that originated with XFree86 and has been inherited by the X.org project; since this is an extension to the X11 protocol, not all servers will be equipped with it.

A basic client program for displaying and adjusting the X server’s gamma value is xgamma. Used by itself, it will display the current gamma correction factors:

$ xgamma
	-> Red  1.000, Green  1.000, Blue  1.000

To set the correction factors, use the -gamma option to set the same value for all channels, or use -rgamma, -ggamma, or -bgamma to adjust just one channel:

	$ xgamma -gamma 1.5152
	-> Red  2.000, Green  1.000, Blue  1.000 
	<- Red  1.515, Green  1.515, Blue  1.515
	$ xgamma -rgamma 2
	-> Red  1.000, Green  1.000, Blue  1.000 
	<- Red  2.000, Green  1.000, Blue  1.000

The values marked -> show the previous gamma settings; the values marked <-are the new settings.

Note that the gamma values are passed to the server with three decimal places.

For systems with multiple displays, you can apply a specific gamma correction to a single display by running xgamma with the -display option. When you’re using a Xinerama display, you may need to set the gamma for just one monitor, but you can’t specify the screen in the displayspec (because Xinerama counts all of the physical screens as part of one logical screen). The -screen option lets you specify the physical screen to be queried or adjusted:

	$ xgamma -display :0.0 -screen 2 -gamma 1.3
	-> Red  1.000, Green  1.000, Blue  1.000
	<- Red  1.300, Green  1.300, Blue  1.300

Values set with xgamma are temporary—they will be reset when the X server is reset or restarted. To permanently set the gamma correction factors when using the X.org server, use a Gamma entry in the Monitor section of the xorg.conf file:

	Section "Monitor" 
	        Identifier   "Monitor0" 
	        VendorName   "Samsung" 
	        ModelName    "205BW" 
	        HorizSync    28.0 - 55.0 
	        VertRefresh  55.0 - 70.0
	        Option       "DPMS"
	        Gamma 1.21 1.30 1.22
	EndSection

The arguments to the Gamma entry are separate red, green, and blue gamma values; you can instead write a single value that will be applied equally to all channels.

But what values should you set? That’s a difficult question, because the answer depends on that material being displayed, the monitor hardware, and lighting conditions. In most cases, you’ll want your display’s effective gamma to be around 2.2 (as defined in the sRGB specification), but it’s hard to know what correction factor will give that to you.

To answer this question, Norman Koren has produced a set of web-based charts that let you test and adjust your monitor’s gamma by eye. These charts are available at http://www.normankoren.com/makingfineprints1A.html.

The GAMMApage software available from Paul Sherman at http://www.pcbypaul.com/software/GAMMApage.html uses Norman Koren’s charts to provide an interactive toolfor gamma adjustment.

Color Management Systems

For most purposes, the color accuracy provided by modern computer systems and peripherals as shipped from the manufacturer is sufficient. But higher-accuracy color reproduction is critical for certain types of work, including professional photography, graphic design, and fashion. A color management system ( CMS) uses a numeric model of an output device to accurately map between a color space and that device. The device model is called a profile; the International Color Consortium ( ICC) manages and promotes specifications for vendor-neutral, cross-platform color profiles.

In X11R5, the X Color Management System (Xcms) was introduced, based on tech-nology provided by Tektronics. Xcms was primarily concerned with loading display color correction tables into the root window properties, and then using these properties within client programs to adjust the colors drawn on the screen—but Xcms was poorly documented and never really caught on, and it did not use ICC profiles.

Two open source projects now provide color management capability for X:

Argyll (http://www.argyllcms.com/)

A set of command-line tools for calibrating displays, printers, and scanners, and for setting the CLUT for displays, as well as client-side libraries for color space conversion .

LittleCMS (http://www.littlecms.com/

A very compact color management library designed for use by applications. It supports color management for displays, printers, and scanners using color profile files, but it does not include tools for generating those profiles.

LittleCMS is used by many open source applications (including CinePaint [Holly-wood’s version of the Gimp], the Gimp version 2.3 and higher, Scribus, XSane, and digiKam), and it is becoming the de facto standard for client-side color management.

Tip

In most applications that use LittleCMS, color management will be disabled by default. You will need to enable color management in each application and select the correct profiles for your devices.

Profiles for LittleCMS may be supplied by the manufacturer, loaded from a tool used in another operating system, or created with Lprof (http://lprof.sourceforge.net/), which is an open source profile editor that can produce rough monitor profiles using subjective tests.

To produce very accurate color profiles, you will need a color target (for input calibration—such as scanners and cameras) or a colorimeter (for output calibration— such as printers and monitors). Color targets are fairly readily available, but colorimeters that work with X11-based systems are quite rare. (And, colorimeters are generally expensive, often costing as much as the monitor or printer being calibrated.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.174.19