{"id":258,"date":"2006-10-03T17:45:30","date_gmt":"2006-10-03T08:45:30","guid":{"rendered":"https:\/\/regex.info\/blog\/photo-tech\/color-spaces-page6"},"modified":"2006-10-03T13:36:46","modified_gmt":"2006-10-03T04:36:46","slug":"color-spaces-page6","status":"publish","type":"page","link":"https:\/\/regex.info\/blog\/photo-tech\/color-spaces-page6","title":{"rendered":"Digital-Image Color Spaces, Page 6: Design Tradeoffs"},"content":{"rendered":"\n\n<style type='text\/css'>\na.btn    { background-color: #555; border: solid 1px #888; padding: 2px 5px }\nspan.now { background-color: #533; border: solid 1px #888; padding: 2px 5px; font-weight: bold }\n<\/style>\n<div style='display: block; background-color: #444; padding: 7px; border: solid 2px gray'>\n<b>Article:<\/b>\n<a class='btn' href='\/blog\/photo-tech\/color-spaces-page0\/'>Table of Contents<\/a> &nbsp; &nbsp; &nbsp; <b>Page:<\/b>\n<a title='Introduction' class='btn' href='\/blog\/photo-tech\/color-spaces-page1\/'>1<\/a> &middot;\n<a title='Test Images' class='btn' href='\/blog\/photo-tech\/color-spaces-page2\/'>2<\/a> &middot;\n<a title='Color Mis-Management' class='btn' href='\/blog\/photo-tech\/color-spaces-page3\/'>3<\/a> &middot;\n<a title='Color Management' class='btn' href='\/blog\/photo-tech\/color-spaces-page4\/'>4<\/a> &middot;\n<a title='Chromaticity Diagrams' class='btn' href='\/blog\/photo-tech\/color-spaces-page5\/'>5<\/a> &middot;\n<span class='now'>6<\/span> &middot;\n<a title='Conclusions and Links' class='btn' href='\/blog\/photo-tech\/color-spaces-page7\/'>7<\/a>\n<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is the sixth page of a seven-page article<\/small>\n<\/div>\n\n<p>So, what factors make a color space good? Many of the issues can be\nsummarized with two statements, both of which describe a good color space:\n&#8220;<b>bigger is better<\/b>&#8221; and &#8220;<b>smaller is\nbetter.<\/b>&#8221; The mutually-exclusive nature of these goals indicates\nthe contentious tradeoffs that must be made during color-space design.\n\n<\/p>\n\n<p><b>Illustrative Example: <i>Length<\/i><\/b><\/p>\n\n\n<p>Just to give a feel for the issues and tradeoffs facing color-space\ndesigners, let's take a simplistic look at how we might encode something\nfar simpler than color: <b>length<\/b>.\n\n<\/p><p>\n\n(To be clear, this example has nothing to do with photography &mdash; it's\njust an example to illustrate the nature of digital &#8220;space\nencoding&#8221; tradeoffs. Being familiar with these issues helps you to\nunderstand discussions of the relative merits of color spaces).\n\n<\/p>\n\n<p><b><a name='Unlimited'>Perfection is Possible, For a Price<\/a><\/b><\/p>\n<p>\n\nFirst, it seems prudent to note that if we had unlimited space to encode\nour length, we would not have to make any tradeoffs. With unlimited space,\nwe could pick any unit (say, millimeters) and know that we could exactly,\nunambiguously, perfectly encode any length we wished, from the <a\nhref='http:\/\/en.wikipedia.org\/wiki\/Planck_length' class='quiet'>Planck\nlength<\/a> (<tt\nstyle='font-size:85%'>0.000000000000000000000000000000001616241<\/tt>) to\nthe guesstimated size of the visible universe down to more significant\ndigits than can ever be known (<tt\nstyle='font-size:85%'>137198261174792827472661283376.9087225566893726264897726289572<\/tt>).\n\n<\/p><p>\n\nModern digital images can have tens of millions of pixels, so it can be\nunwieldy to let the encoding space requirements expand without bound.\nPeople like fitting a lot of pictures on their memory cards and hard disks.\nFinding a way to encode as much information as possible in the minimum\nspace brings us face to face with the need for tradeoffs.\n\n<\/p>\n<p><b><a name='Trivial'>Trivial Attempts to Encode Length: Width vs. Precision<\/a><\/b><\/p>\n<p>\n\nBack to our length example, let's say that file-size concerns dictated that\nwe use only three digits to encode the length, which means raw numbers from\n0 to 999 for each length we wish to encode. It's up to us now to design a\n&#8220;length space&#8221; as best we can within that limitation.\n\n<\/p><p>\n\nIf we select the millimeter as our unit, we could encode lengths up to 999\nmm (just over a yard) with fairly fine granularity (our 1 mm units). This\nmight be fine for encoding the lengths of some things (say, shoes and car\ntires), but remains woefully lacking for most things (widths of hairs and\nthe heights of mountains).\n\n<\/p><p>\n\nIf we choose a larger unit to apply to the raw numbers, such as a foot,\nthen we can encode lengths up to about a third of a kilometer &mdash; a\nmuch <b>larger gamut<\/b>, so to speak. The tradeoff is that the level of\n<b>precision<\/b>, or granularity &mdash; how fine a point along the full\nencodable range that can be defined &mdash; has become more rough (in\nencoding-space lingo, the &#8220;quantization errors&#8221; are larger). We can now\nmeasure building heights fairly reasonably (to within a foot), but people\nheights become iffy because everyone's height gets rounded off to the\nnearest foot. In this case, the loss of precision has totally eliminated\nencoding the size of marshmallows.\n\n<\/p><p>\n\nRegardless of the unit we pick, when we use a strictly linear approach as\nwe have above, we run into the same tradeoff: gamut size vs. precision.\n\n<\/p>\n\n<p><b><a name='Shift'>Shifting the Range<\/a><\/b><\/p>\n\n<p>\n\nOne idea is to shift the starting point so that the gamut lies over the\narea we might be interested in. Consider this:\n\n<\/p>\n\n<div style='margin: 30px'><center><big><i>length in millimeters<\/i> &nbsp;&nbsp;<b>=<\/b>&nbsp;&nbsp; 457 + <i>value<\/i> &times; 2<\/big><\/center><\/div>\n\n<p>This allows our values from 0 through 999 to encode lengths from 457mm\nthrough 2,455mm (18 inches through 8 feet) to a granularity of 2 mm, which\nwould be a useful length gamut for encoding the height of people. I'm not\nsure it would be much use for anything else, but it illustrates the\npoint.<\/p>\n\n<p><b>(Having shown an equation, I should remind you that this is all just\nan example to illustrate tradeoffs with encodings &mdash; I'm making this\nup as I go along, so there's no need to memorize or even pay any real\nattention to these equations!)<\/b><\/p>\n\n<p><b><a name='NonLinear'>Going Non-Linear<\/a><\/b><\/p>\n<p>\n\nOne technique to achieve better encoding performance is to bring an\nunderstanding of human perception into the equation. When considering the\nheights of people, an inch or two either way can be a big deal, but the\nsame difference is generally much less relevant when considering the\ndistance between cities. So, one technique is to use a non-linear encoding\nsuch that the precision increases as the length gets shorter. Put another\nway, the difference between adjoining encodable lengths is smaller when the\nlength is smaller, and larger when the length is larger. This fits to the\nway people generally think.\n\n<\/p><p>\n\nFor\nexample, using this equation (which I just made up off the top of my head) in our encoding:\n\n<\/p>\n\n\n<table border='0' align='center' style='margin:30px auto'>\n<tr>\n  <td valign='bottom'><big><i>length in millimeters<\/i> &nbsp;&nbsp;<b>=<\/b>&nbsp;&nbsp;<\/big> <span style='font-size:280%'><i>e<\/i><\/span><\/td>\n  <td valign='bottom'><center><small><u>&nbsp;&nbsp;&nbsp;37&nbsp;&nbsp;&nbsp;<\/u><br\/><i>value<\/i><br\/>&nbsp;<br\/>&nbsp;<\/small><\/center><\/td>\n  <td valign='bottom'><span style='font-size: 180%'>- 1<\/span><\/td>\n<\/tr>\n<\/table>\n\n\n<p>\n\nwith <i>values<\/i> from 0 through 999 allows us to represent lengths from\nbetween 0.027 millimeters through more than half a million kilometers.\nThat's from about 1\/<sub>1,000<sup>th<\/sup><\/sub> of an inch (thinner than\nthe width of an average human hair) to a distance beyond the moon. That's a\n<b>wide<\/b> length gamut.\n\n<\/p><p>\n\nYet, despite the convenient width, it still allows the lengths of many\nthings to be encoded with &#8220;reasonable&#8221; precision &mdash; to\nwithin a percent or so of their actual length. For example, it can encode\nthe length and width of a pencil to within 0.3%, the length of my foot to\nwithin 1.2%, the length of a soccer field to within 0.6%, the height of Mt.\nEverest to within 0.4%, the diameters of the earth to within 0.1% and of\nthe moon to within 0.3%, and the distance to the moon to within 0.2%.\n\n<\/p><p>\n\nThat's not too bad, and if someone like me can come up with that off the\ntop of my head, someone with real mathematical skill might be able to make\none that's even better.\n\n<\/p>\n\n<p><b><a name='Shift'>Back to Color Spaces<\/a><\/b><\/p>\n\n<p>\n\nThere are a lot of things about color that can be used to one's advantage\nwhen designing a color space:<\/p>\n\n<ul>\n\n<li><p>A lot of colors look the same. Whole ranges of wavelengths look more\nor less exactly the same to most people, so those regions of color need not\nbe encoded with much precision. An encoding space is better if it can use\nthe available precision where it counts the most.<\/p><\/li>\n\n<li><p>The same can be said of the range of colors covered. This is one\nreason that the monochromatic colors are <a\nhref='\/blog\/photo-tech\/color-spaces-page5\/#Monochromatic'>not\ngenerally included<\/a> in RGB color spaces: exceedingly similar colors can\nbe included in their place without having to extend the gamut all the way\nto the edge. Most people just can't tell the difference, so the smaller\ngamut is used to provide more precision across the encoded space.<\/p><\/li>\n\n<li><p>As mentioned on the <a\nhref='\/blog\/photo-tech\/color-spaces-page5\/'>previous\npage<\/a>, the eye's perception of brightness is not linear with the\nintensity of light. Thus, it's a more efficient use of the available\nprecision if the brightness component of the color can be encoded in\nproportion to how the eye perceives brightness. This is usually done with a\n<a href='http:\/\/en.wikipedia.org\/wiki\/Gamma_correction'>gamma<\/a>.\n<\/p><\/li>\n<\/ul>\n\n<p>In the end, the width vs. precision tradeoff is always there. If a color\nspace is designed for a specific purpose, at least it can use features of\nthe intended use to squeeze out extra efficiency (sRGB bothered to encode\nonly the colors that circa-1996 common monitors could display, for\nexample). A general-purpose color spaces are a more difficult subject;\nhopefully, this page has provided some insight into some of the issues.<\/p>\n\n<p><b>Continued on the Next Page<\/b><\/p>\n<p>\nThis article continues on <a href='\/blog\/photo-tech\/color-spaces-page7\/'>Page 7: Recommendations and Links<\/a>.\n<\/p>\n\n\n\n\n\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>So, what factors make a color space good? Many of the issues can be summarized with two statements, both of which describe a good color space: \"<b>bigger is better<\/b>\" and \"<b>smaller is better.<\/b>\" The mutually-exclusive nature of these goals indicates the contentious tradeoffs that must be made during color-space design. <\/p> <p><b>Illustrative Example: Length<\/b><\/p> <p>Just to give a feel for the issues and tradeoffs facing color-space designers, let's take a simplistic look at how we might encode something far simpler than color: <b>length<\/b>. <\/p><p> (To be clear, this example has nothing to do with photography -- it's just an example [...]","protected":false},"author":1,"featured_media":0,"parent":251,"menu_order":6,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/pages\/258"}],"collection":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/comments?post=258"}],"version-history":[{"count":0,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/pages\/258\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/pages\/251"}],"wp:attachment":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/media?parent=258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}