The mathematics of TrueColor (and what it has to do with legal education)

Editor's note: This post reprints my February 2008 column for Bar Briefs, the monthly newspaper of the Louisville Bar Association, and is based on a post on MoneyLaw.

CIE chartWith apologies to T.S. Eliot and the Internal Revenue Service, February is the cruelest month. Dark nights and frozen sidewalks greet us, mixing memory and desire, stirring dull thoughts with winter pain.

This I remember, and this I love. Composing posts on The Cardinal Lawyer has rekindled an old passion of mine. Somewhere in my distant past, between North Avenue and Druid Hills, on the path from a engineer's regimen at the Georgia Institute of Technology to a haphazardly assembled prelaw curriculum at Emory University, I neglected my fervor for mathematics in motion. Of late, personal involvement in the HTML coding of The Cardinal Lawyer gave me occasion to explore the mathematics of TrueColor. And now footfalls echo in my memory down a passage I did not take, towards the door I now will open into the rose-garden.

As I tried to create a graphic on my own computer, I needed to designate a precise color. "What color?" asked Microsoft Paint. "Ochre," I replied. But the oracle of Redmond understood me not. She demanded values in red, green, blue.

In despair, I asked, purveyor of the Web's easiest color calculator. "DDDD99," I muttered. "221 221 153," replied EarthWeb.

And thus the hex was broken.

The six-digit codes designating TrueColor values represent the culmination of longstanding efforts to master the fascinating mathematics of color perception by humans in order to direct color production by machines. The graphic at the top of this post depicts the first step. The CIE (Commission International d'Éclairage) mapped human color perception onto the two-dimensional chart depicted here. Using the CIE chart, as French as the metric system but as intuitive as fathoms and furlongs, proved as easy as charting great circle routes on a flat map.

HSV coneThe CIE color chart gave way to the more geometrically satisfying HSV system for expressing color as a function of hue, saturation, and value. The HSV model resembles a cone, and slicing it generates conic sections that express some portion of the universe of visible color in a useful way. The whole enterprise is vaguely reminiscent of navigating according to spherical coordinates.

So much for modeling how the human eye perceives color. How can a machine produce the 10 million different colors that the sharpest human eye can see? Coding the visible spectrum as different portions of red, green, and blue — with each constituent color assigned eight bits of information — yields 256 x 256 x 256 colors, or 16,777,216 in all.

RGB color modelThe unwieldy decimal number 16,777,216 is more elegantly described as 224, or, if you insist, a binary septillion. The exponent, 24, reveals an important truth: 24 bits suffice for the expression of TrueColor. More powerful 32-bit and 48-bit systems enable transparency and sophisticated overlays that are less prone to rounding errors that would otherwise accumulate with each iteration of image filtering.

The familiar RGB (red green blue) color scheme, traceable to the awful days of the four-bit, 16-color palette of IBM's color graphics adapter, is even more helpfully expressed in hexadecimal format. Since 16 x 16 equals 256, base 16 mathematics allow us to express any value from 0 to 255 with exactly two digits. Digits 1 and 2 represent red, digits 3 and 4 represent green, and digits 5 and 6 represent blue. DDDD99 — quite a bit of red and green, with considerably less blue — produces a soothing color often described as "ochre."

Very well then. What does all this have to do with legal education?

Long ago I ran out of fingers and toes to tally the number of legally trained professionals who have confessed bewilderment at the idea that law might — and indeed should — be quantified to the very limits of mathematics. Mastery of mathematics confers almost boundless power to describe the world and to prescribe solutions for its flaws. Law school, so these individuals confessed, was a refuge from numbers, equations, graphs. Check your probability distributions at the door. We went to law school because we bombed the GMAT, much less the MCAT.

Ah, but there lies the rose-garden. The world is filled with problems that can be expressed in numbers. If the law harbors any hope of solving those problems, it cannot afford to discard so basic a tool as mathematics. I offer this wish for the legal academy: Would it be that our profession no longer confessed — no longer cherished — its rampant innumeracy. Would it be that the law, reunited with the tools of quantitative analysis and reinvigorated with an appreciation of mathematical beauty, might cease to be the mathematical waste land of the social sciences.