Saturday, March 18, 2006

Linear Color Space Editing

In my last post I said that gamma adjusted color spaces are bad for image editing.

First off, I am one of those that saw the light reading and hasn't recovered yet.

Indeed the entire LightZone project started from the "discovery" that linear color space editing is the thing to do.

I have learned recently that the internet has been a hot place for a while, when the gamma proponents/opponents have been flaming each other for a while.

I don't wish to reheat old flames, but I have to say something all the same.

Gamma encoding has its roots far back in the early days of TV broadcast when the industry had to produce reasonably priced TV sets: to lower costs signal processing in TV receivers should be minimal.

The CRT tube has a non linear transfer function that needs to be compensated to display images properly. To avoid processing the image in the receiver the signal was pre-processed at broadcast time to compensate for the CRT transfer function. This seems to have been the birthplace for the gamma encoding we have in images today:

output_intensity = input_intensity ^ gamma

There actually seems to be a good reason why digital images are gamma encoded. Eight bits per color is not a lot and without gamma encoding for images it would be easy to have banding artifacts in color images.

Gamma encoding seems to be an effective way of performing a perceptually adjusted lossy image compression, using relatively more bits to represent darker parts of the image than for the lighter ones. This is convenient because the eye has a logarithmic sensitivity scale and it sees banding more in the shadows than in the highlights.

With modern computers with lots of RAM and fast CPUs we can afford processing images with 16 bits of precision per channel, which is plenty of resolution for all practical purposes.

At this point there is no excuse anymore to edit images in gamma space, Timo Autiokari has expounded in detail the errors induced by gamma editing, please take a look at his very interesting site:

The problem of linear editing is that tools like Photoshop have been designed with gamma adjusted images in mind. Linear encoded images have most of the "stuff" in the low pixel numeric values and very little in the higher values.

Using curves and histograms in Photoshop with a linear color space is a daunting task. All the information is bunched up in the left side of the histogram making it very hard to evaluate the characteristics of the image. Similarly all the curve work has to be done in a tiny region close to the origin of the curves tool. Very impractical.

In LightZone we use different tools from Curves and Histograms: the Zone Mapper and the Zone Finder. These tools are well adapted to working in a linear color space because they present the information too the user in a logarithmic scale, thereby spreading the intensity information across a large range of values which is using effectively the computer screen real estate and allows to conveniently adjust images on a scale that is natural for the eye.


At 5:40 AM, Blogger Mike said...

Wow! I just found out about linear editing myself and I fully agree with you. It pays off bigtime.

I currently use a workflow based on a bash script that calls DCRAW and ImageMagick's convert utility to get around this hurdle, but it only works on batches of well-exposed, colourcast-free images and it is limited to my camera, the Powershot Pro1.

I am anxious to try out Lightzone and I will download the Linux version if it is still available.

At 8:35 AM, Blogger Samir said...

I have been using LZ2.0 for about 1 month and I love it. But to be honest I fail to understand what is it you don't like in Photoshop. Could you better explain how different is LZ compared to PS?

At 9:42 AM, Blogger fricc said...

Hi Samir,

my "problem" with photoshop is that it doesn't allow you to develop an intuition. It uses a purely numeric metaphor for image retouching which I believe is foreign to photography.

LightZone tries to use the experience of 150 years of photography, syntesized in the Zone System, to provide you with a tool that allows you to directly relate to your images and what you want to do with them, withour artificial numeric intermediaries...


- Fabio

At 9:35 AM, Blogger andrewrodney said...

Fabio, do you release that virtually every serious color scientist working with imaging, many of the Photoshop engineers, and a pile of other's in the imaging industry have labelled Timo's theories as patiently ridiculously and have done so for many, many years.

At 11:27 AM, Blogger fricc said...


yes I know that Timo's stuff is controversial, but I think that he's spot on on most of what he's talking about. I'm an engineer (I have a master degree in EE and a PhD in CS) and I've been doing signal processing in many different fields for all my life, long enough to understand that gamma adjusted color spaces are not good for serious image processing.

Adobe seems to have gotten that too and I hear that Lightroom uses a linear color space internally too.

My opinion about "every serious color scientist working with imaging" is actually not very high.

As of today color science is vastly vodoo science, a pile of controversial information, half baked theories developed in a particular context and used in another where they do not really apply. Most of the stuff is obsolete and unapplicable to modern imaging and you really wonder how come nobody can write a decent book about modern digital image processing.

Moreover the issue is largely political, where the opinions of the "serious color scientists" are usually used to protect vested interests of large corporations. Poor Timo from Finland doesn't stand a chance...

At 1:48 PM, Blogger Andrew said...

Well Timo could feel vindicated because if you bring an existing rendered image into Camera Raw or Lightroom, it's getting converted to a linear encoded color space with ProPhoto primaries for ALL processing (sometimes in 8-bit OUCH). Printing too (unless its draft mode).

At 2:07 PM, Blogger fricc said...

Well, maybe Timo sleeps better now ;^)


Post a Comment

Links to this post:

Create a Link

<< Home