{"id":93,"date":"2015-04-06T15:57:56","date_gmt":"2015-04-06T15:57:56","guid":{"rendered":"http:\/\/threadlocalmutex.com\/?p=93"},"modified":"2015-04-06T15:57:56","modified_gmt":"2015-04-06T15:57:56","slug":"dithering-in-gamma-vs-linear-space","status":"publish","type":"post","link":"http:\/\/threadlocalmutex.com\/?p=93","title":{"rendered":"Dithering in Gamma vs. Linear Space"},"content":{"rendered":"<p>Here is some public domain image, originally created by <a href=\"http:\/\/en.wikipedia.org\/wiki\/User:Ricardo_Cancho_Niemietz\" title=\"Ricardo Cancho Niemietz\">Ricardo Cancho Niemietz<\/a>.<\/p>\n<figure id=\"attachment_97\" aria-describedby=\"caption-attachment-97\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot8888.png\"><img loading=\"lazy\" src=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot8888.png\" alt=\"Original 8888 color image\" width=\"410\" height=\"200\" class=\"size-full wp-image-97\" srcset=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot8888.png 410w, http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot8888-300x146.png 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/a><figcaption id=\"caption-attachment-97\" class=\"wp-caption-text\">Original 8888 color image<\/figcaption><\/figure>\n<p>Conversion to R4G4B4A4, without application of dithering, yields a rather unsightly result. Note the significant color banding on the gradients, which results in the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Mach_bands\">Mach band optical illusion<\/a>. There is some heavy color banding of the parrot's plumage as well.<\/p>\n<figure id=\"attachment_96\" aria-describedby=\"caption-attachment-96\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444.png\"><img loading=\"lazy\" src=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444.png\" alt=\"Non-dithered 4444 color image\" width=\"410\" height=\"200\" class=\"size-full wp-image-96\" srcset=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444.png 410w, http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444-300x146.png 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/a><figcaption id=\"caption-attachment-96\" class=\"wp-caption-text\">Non-dithered 4444 color image<\/figcaption><\/figure>\n<p>Dithering improves the artifacts and replaces most of banding by visually less-objectionable high-frequency noise.<\/p>\n<figure id=\"attachment_94\" aria-describedby=\"caption-attachment-94\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered.png\"><img loading=\"lazy\" src=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered.png\" alt=\"Dithered 4444 color image\" width=\"410\" height=\"200\" class=\"size-full wp-image-94\" srcset=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered.png 410w, http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered-300x146.png 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/a><figcaption id=\"caption-attachment-94\" class=\"wp-caption-text\">Dithered 4444 color image<\/figcaption><\/figure>\n<p>However, you may notice that there now appear slightly darkened stripes in the linear gradients on the right side where the undithered image jumps to the next color level. This is because the image has been dithered in gamma space where adding up color values results in a color with slightly lower intensity. Linearizing color values before computing and distributing the error, these artifacts disappear completely:<\/p>\n<figure id=\"attachment_95\" aria-describedby=\"caption-attachment-95\" style=\"width: 410px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered_sRGB.png\"><img loading=\"lazy\" src=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered_sRGB.png\" alt=\"Dithered 4444 color image with sRGB correction\" width=\"410\" height=\"200\" class=\"size-full wp-image-95\" srcset=\"http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered_sRGB.png 410w, http:\/\/threadlocalmutex.com\/wp-content\/uploads\/2015\/04\/parrot4444_dithered_sRGB-300x146.png 300w\" sizes=\"(max-width: 410px) 100vw, 410px\" \/><\/a><figcaption id=\"caption-attachment-95\" class=\"wp-caption-text\">Dithered 4444 color image with sRGB correction<\/figcaption><\/figure>\n<p>Visually, there's little advantage of using sRGB-correct dithering for high-frequency photographic images, as the differences are neglible. For low-frequency gradients the gain in quality is obvious; however images with perfect gradients are most likely lookup tables and the like that wouldn't be stored at low color depths in the first place.<\/p>\n<p>Anyway, the result using an approximate (and cheaper) gamma exponent of 2.0 is visually completely indistinguishable from applying the proper sRGB conversion for the purposes of dithering, so there's that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is some public domain image, originally created by Ricardo Cancho Niemietz. Conversion to R4G4B4A4, without application of dithering, yields a rather unsightly result. Note the significant color banding on the gradients, which results in the Mach band optical illusion. There is some heavy color banding of the parrot's plumage as well. Dithering improves the <a class=\"read-more\" href=\"http:\/\/threadlocalmutex.com\/?p=93\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[],"_links":{"self":[{"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=\/wp\/v2\/posts\/93"}],"collection":[{"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93"}],"version-history":[{"count":7,"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":104,"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions\/104"}],"wp:attachment":[{"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/threadlocalmutex.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}