RawTherapee's CIECAM02 module

(Elle Stone) #1

I’m trying to use RT’s CIECAM02 module as a step in a workflow where most of the editing is done in GIMP 2.9. I’ve read through “http://rawpedia.rawtherapee.com/CIECAM02” several times, but I still have questions.

Starting with RT’s “Preferences/Color Management/CIECAM02-Specific Settings”:

Question 1. Output device’s white balance:

As the output from RawTherapee will be opened in GIMP for further processing, I’m assuming that the output device white balance is the monitor “color of white”?

Or does the fact that I’m using ICC profile color management in RT and in GIMP mean that the “output device white balance” is D50/5000K?

Question 2. Output device’s Yb luminance:

The default option is “Yb=18 CIEL#50”, which I take to mean middle gray, which is L=50 or R=G=B=0.18 floating point, assuming a linear gamma RGB color space. But what does this mean in terms of the “output device”?

Does “Output device’s Yb luminance” mean the “wallpaper frame” around the image as displayed? So as the RT-modified image will be reopened in GIMP, maybe the canvas padding in GIMP should be L=50?

And in RT “Output device’s Yb luminance” would be the background in the RT theme? In which case maybe the RT theme background color choice should be in the CIECAM02 settings? Unfortunately the brightest supplied theme (TwoWaBlue-Bright) seems to have the background of the image at around Y=35, and the left panel is considerably darker.

Question 3. Scene Yb luminance:

Is this part of “Process 1”? I’m guessing this is the average relative luminance of the image, yes? Or is this based on the actual brightness of the scene as shot, based on the image exif data?

(Morgan Hardwood) #2


(Desmis) #3

Very difficult for me to express myself in English on this complex subject to explain, even in French

What you are asking for in 1) and 2) corresponds to the Rawpedia “Process 3” chapter.
“Ouput device” corresponds to what, where, under what conditions you visualize the output of RT.
Is it : a) on a computer monitor - the same as that of the processing - ; b)is it on an external projector, or a c) television, is it a d) printer output, etc.

Also under what conditions you visualize.
A) Is the room in the dark, or conversely almost in full light
B) is the “device” set correctly - which may seem fairly obvious to a computer, is less so for a projector or a TV
C) Is the projection’s surroundings the same shade of gray as the projection, or darker, or lighter

For question 3) only the person who took the picture, who knows the real conditions of the “scene”.
In this case, after a pass by Gimp, it seems difficult to choose anything other than the default settings made from the Exifs.
But “scene luminosity” corresponds to the true illumination at the time of the shooting


(Elle Stone) #4

Hi @jdc , and thank you very much for responding. I had two contexts for asking about the CIECAM02 settings.

The first context is no longer applicable, being some unknown combination of user error and software instability. For some reason the image as shown in the RT UI didn’t look anything like the image as saved to disk and imported into GIMP. The usual “different color management settings” did not apply. I had installed the GTK3 stable version from OpenSUSE Tumbleweed, and it wasn’t very stable:

  • The CIECAM02 module kept disappearing, leaving only the little description section visible, with no way to show the actual sliders. The only way to get the CIECAM02 panel back was to exit RT and then delete all the user RT configuration files and start over - this happened so frequently that it was difficult to actually get an image saved to disk.
  • Also the left panel wasn’t resizeable, instead would start to resize and then flick back to the default width.

So I uninstalled the GTK3 version and installed the GTK2 version. It took a couple of configuration file deletions and restarts before the CIECAM02 module “stayed put”. But now everything is fine. And it’s entirely possible that the “looks different” problem was partially or entirely stupid user error from comparing actually different images - I have trouble remembering that RT’s default export folder isn’t the same as the folder from which the image was opened for processing.

The second context is that previously I never used the CIECAM02 module, precisely because the CIECAM02 color management options in Preferences ask about the display device and I didn’t know what the right settings should be:

  • I think that if the context is using ICC profile color management, and displaying the image on the same monitor that’s used for editing, then the display “white” in Preferences/Color Management should be D50 - is this wrong?

  • If the image were to be displayed on a calibrated but non-color-managed monitor (like a TV screen), then likely the actual white point of the device would be the right value, yes?

I decided to try using the RT CIECAM02 module, even not knowing the Color Management settings, because I was using GIMP 2.9’s LCH color tools and blend modes to make a night scene rendition of a photograph taken during daylight. I was having trouble getting the shadow tonality to be sufficiently dark without losing detail completely. It occurred to me that the RT CIECAM02 module might be used to solve the problem, and indeed RT worked very nicely for this purpose. This is why I was asking about “scene luminance” and how it was calculated:

  • The image that I exported to disk from GIMP and opened with RT didn’t have any embedded exif information.
  • Even if the image had contained all the exif information from the raw file, that information wouldn’t be relevant to the image that was actually exported from GIMP, because the image had already been considerably modified to make a night scene from a day scene.
  • Even if the camera raw file from which the image was processed were directly opened in RT, the embedded exif information doesn’t contain the f-number which the RT “on hover tooltip” says is used to make scene luminance calculations, because my manual lenses don’t communicate that information to the camera.

Anyway, I liked the way the RT CIECAM02 module allowed me to modify the GIMP-produced shadow tonality so much that I decided to try using RT to make a night scene from the day scene starting directly from the camera raw file, and that worked out pretty well, too, at least for the tonality. I didn’t really like the color so much, but I’m not all that familiar with using RT. If anyone is curious, the RT-made night scene and some notes on the CIECAM02 settings is on this page under “Processing note”: http://ninedegreesbelow.com/photography/day-into-night.html

(Desmis) #6

In general if you use the same monitor for “output” as for the processing you can leave all the default settings.
But even in this case we must take into account “surround” for “viewing conditions”, in particular because Gtk3 brings a dark image outline by default

In addition nothing is perfect, especially for JPG / TIFF or where if the processing has been done elsewhere, data may be absent or erroneous.
In this case either you choose the default settings, or you use your common sense.:slight_smile:

(Elle Stone) #7

Hmm, I don’t know how I managed to withdraw my previous two posts, that was not my intention, if indeed they were withdrawn. On my computer it says “post withdrawn by author”.

I wanted to add a follow-up post to make my actual questions more clear.

CIECAM02 module has a subsection called Scene Conditions, with a slider that is labelled CAT02 Adaptation. The default is 100% adaptation. But there is a slider to allow less than 100% adaptation, up to and including no adaptation.

Adaptation implies from one viewing condition to another viewing condition. The on-hover tooltip indicates that the “adaptation” in question is chromatic adaptation, so the adaptation is from one white point (source) to another white point (destination).

Here are my actual questions:

There seems to be no way to set the source white point and destination white point to the same value, such that the degree of adaptation makes no difference. I’m trying to figure out why.

I’d like to know what user-controllable settings can be used to make the degree of adaptation not matter.

Here is some context and additional questions:

There are two “WP Models” to choose from, described as follows:

  1. WB [RT] + [output]: RT’s white balance is used for the scene, CIECAM02 is set to D50, and the output device’s white balance is set in Preferences > Color Management

  2. WB [RT+CAT02] + [output]: RT’s white balance settings are used by CAT02 and the output device’s white balance is set in Preferences - Color Management.

Either way, “RT’s white balance” is used, probably as the source white point.

What does “CIECAM02 is set to D50” mean? Is there some other D# (or E or etc) used for the second Model?

Currently I have the output device white balance set to 5000K. The output device is my monitor, and I’m using ICC profile color management, so it seems to me that D50 is the right white balance to choose for the output device. Is this correct?

I’m guessing that “RT’s white balance” is set in the Color/White balance" module. Is this true?

RT’s white balance defaults to Temp 6490/Tint 1.002. Where do these default numbers come from? Why are they appropriate for an image opened from disk?

The default white balance seems wrong for an image opened from disk. In an ICC profile color-managed editing application, with D50 being the white point of edited images, it seems to me that this default white point for non-raw images should be D50, not Temp 6490/Tint 1.002. Is there some point that I’m missing, that makes the default white balance appropriate for non-raw images opened from disk?

If the “RT white balance” sliders are moved from the default values the image white balance is modified such that neutral gray is no longer neutral gray. So this is not something the user has control over unless their intention really is to modify the white balance.

(Morgan Hardwood) #8


I don’t know about the how part (though, do you have a cat?), but you can revert it by clicking on the edit button in the top-right corner:

(Elle Stone) #9

Hmm, thanks! I still couldn’t figure it out, but it doesn’t matter. I’ve re-asked the questions hopefully in a more clear manner, so I’ll just leave the previous post deleted.

No cat! And my dog knows better than to do any typing when I leave the room :slight_smile: .


@Morgan_Hardwood Maybe I am missing something but there is no option to revert in the History popup window.

@Elle Are you trying to figure out how to set the module so that it is essentially in a pass-through state? Then after understanding that you would begin to push the scene toward other conditions? So far, I have stayed away from the module because CIECAM02 is too much for me to handle :blush:.

(Elle Stone) #11

@afre - Yes, my first question is how to get as close as possible to “no change”. I’m not all that interested in dealing with what the image will look like as displayed on some “other device” because at the point where I want to use the CIECAM02 module, I’m still editing the image.

I like to understand the tools that I use in my digital darkroom. The RT CIECAM02 module seems pretty powerful, and I’d like to understand something of what’s really happening when using this module, rather than just twiddle dials and hope that eventually I see something that I like.

As part of figuring out how the the RT CIECAM02 module works, my first goal is to figure out what specific settings for the “Scene Conditions”, “Viewing Conditions”, and “Colors/White Balance” result in “no change at all”, or at least minimal change, before I actually start using the algorithms provided under “Image Adjustments”. Here’s what I’ve found so far:

There are three parts to the RT CIECAM02 module:

  1. Scene Conditions
  2. Image Adjustment
  3. Viewing Conditions

The CIECAM02 module does interact with the White Balance set on the Color tab.

Whether for a raw file or an already processed file from disk, these CIECAM02 settings seem to produce minimal change:

A. Under “Preferences/Color Management” set:

  • Output device’s white balance to “6500K” (regardless of your monitor’s actual white point)

  • Output device’s Yb Luminance and the Scene Yb luminance to “Yb=18 CIEL#50”

B. Set the Colors/White Balance to Temperature 6490/Tint 1.002 and leave the B/R equalizer at 1.000. Of course this won’t be the correct White Balance for most raw files.

C. Activate the CIECAM02 module and make these changes:

  1. Scene Conditions:
* Set CAT02 adaptation to 100%
* Don't check "Dark surround" (use an appropriately lighter theme, which RT doesn't currently seem to provide)
* Choose WP Model: WB[RT+CAT02]+[output]
* Move "Scene luminosity" to maximum value: 16384.000
  1. Image Adjustments: Of course don’t make any image adjustments.

  2. Viewing Conditions:

* Viewing luminosity: Move to maximum value: 1000.0
* Surround: Average
* My test image has a small color gamut and Gamut control seemed to make no difference. For the raw file, under the Raw tab I used the Hot/Dead pixel filters, so I wouldn't expect the Hot/bad pixel filter to do anything, and it didn't seem to.

FWIW, at least with the above settings, the Color tab Input, Working and Output Profiles seem to make no difference. This is true regardless of whether the Scene Conditions degree of adaptation is 0% or 100%. So the “ICC profile” variables probably can be eliminated as affecting the workings of the CIECAM02 module, at least as far as the Scene and Viewing Conditions go.

Question 1: The “minimal changes” produced by activating the CIECAM02 module with the above settings almost looks “as if” a small amount of a really good (artifact-free) sharpening algorithm had been applied or maybe “as if” there were more micro-contrast. The LCH Lightness and Chroma are slightly higher (measured in GIMP using the LCH color picker), and there are very small LCH Hue changes.

Where do these nice “minimal changes” come from?

Question 2: If the Scene Conditions degree of adaptation is set to 0%, then the image looks very different with and without the CIECAM02 module being activated: Moving the degree of adaptation slider to 0 produces a cyan color cast, even if a conversion to black and white is done using the RT “Colors/Black-and-White module”.

Where does this cyan color cast come from? Are source and destination white points somehow different? I keep coming back to this question. Or is there something else going on in the CIECAM02 module that produces the cyan color cast when the adaptation slider is moved to 0%?

(Elle Stone) #12

Nope, that’s wrong. Leave it at the default setting.

(Desmis) #13

I will answer in several times;

I will try to answer without too much theory. Indeed CIECAM02 is very rare in the photo software, can RT almost the only one?
I started from the works on the Web (search), a spreadsheet (Excel) and a few lines of code in C.
I made a lot of interpretations, simplifications and adaptations so that it is quite easily usable.
Since Ingo has re-read the code and improved it especially for the speed of processing.

Starting with CAT02, and WP model:
CAT02 is an adaptation to simulate new values of XYZ in. There are others similar (Bradford, Von Kries)…
XYZ are transformed from RGB and allow an equal energy perception (CIE). Traditionnaly everybody uses this transformation which invovles D50 in calculations.
For example in C++ RT code for Lab2xyz ==> x = 65535.0f * f2xyz (fx) * D50x;

WP model :
I) WB(RT) + output : if you trust the white balance of the photo (of the scene). In this case, RT calculate XYZ scene, with yours values XYZ derivated from RT WB calculation and uses for white D50.
In this same cases, because CIECAM needs the 2 values at beginning, we must give values of XYZ output device.
I have by default considered that your monitor is calibrated at 5000K Which is often the case in Europe, if not change, and if yout device is TV or projector…change it.
By default, I admited that your monitor is well equilibrated (equal repartion of grey, and middle grey Yb=18 with approximation L (Lab) = 50. If not you can change.

For Yb scene values, it is difficult, because only you know what exactly ? If you select “auto” in Preferences, I calculated an approximation with mean of Yb (replace by luminance).
If not you can change.

II) WB(RT + CAT02) + ouput : all the same except for White balance where you do not think WB is good. In this case, RT calcaulated XYZ scene with values calculated by XYZwb and adapttation CAT02.
The system mixed the two with a midlle value. To use CAT02 you must unchecked “automatic” near the slider CAT02 adaptation.

For the scene luminosity, by default I calculated in candelas / m2, I used datas in EXIF, you can change this values, if you remember in what conditions was the scene, near dark, very sunshine, etc.

(Desmis) #14

Always for scene: if you are sure when you took the photo, the surroud was dark, check this value

Now for viewing conditions : generaly we are looking images in a little or big room, with weakened light (16 cd/m2 is a middle value). If you used RT in dark 1 to 5 is better, and in big light…1000.

I insist on Surround, because RT uses gray or almost black surroundings that will require CIECAM to obtain correct effects
Here for the settings of the scene and viewing conditions

Nota : if you want no changes with Ciecam what for me is a nonsense if not why use Ciecam, you must put same values for “Scene luminosity” and “Viewing luminosity” and all defauts settings…but it is a nonsense !!

The following is in the use and understanding of different concepts and settings.
But CIECAM is riddled with known dysfunctions that we will have difficulty solving because they originated from its conception

(Elle Stone) #15

Here are some resources for calculating Scene luminosity:

  1. EV can be calculated from ISO, shutter speed, and f-stop, but only if the image wasn’t deliberately underexposed to avoid blowing out the highlights, or overexposed from ETTR to minimize noise in the shadows:

  2. Fred’s Ultimate Exposure Guide can be used to estimate actual scene EV, assuming you remember the lighting conditions at the time the photograph was taken, or if there’s enough information in the image contents to allow an estimation of the lighting conditions:

  3. This website allows to convert EV to candelas/meter squared:

For example, my “railroad tracks” image was taken on a sunny day, late in the afternoon. So Using Fred’s Ultimate Exposure Guide, I estimate the scene EV to be somewhere between 12.5 and 13.5 EV, let’s say 13.0 EV. Using the “EV to cd/m^2” calculator, the cd/m^2 for the scene is between 724 and 1448, call it 1024.

Ah, thanks! that was the missing bit of information!

I do want to see changes when using the CIECAM02 module. But I’m not using the RT CIECAM02 module the way you envision it being used. I really don’t care how the image will look on some hypothetical display device under some hypothetical viewing conditions. I’m not using the module to prepare a final image for display. I’m using the module as part of an editing process that involves also using GIMP for further editing.

What I want to do is use the CIECAM02 module as part of an editing process to turn “day into night” for a photograph that was taken in late afternoon sunlight. The image has mixed lighting: shade and heavy shade (sky light), and direct sun light. Turning day into night requires several changes made to the image:

  1. A chromatic adaptation change to reflect the change in light sources. But really I think the light sources are the same:
  • The color of moonlight (as reflected off the moon from the sun) when the moon is near the horizon is the color of direct sun light when the sun is near the horizon, yes?
  • The color of the scattered sky light from the sun being not too far below the horizon (less than 18 degrees below the horizon) is still going to be around D65. I’m making assumptions. If someone has better information, please share!
  1. The image needs to be considerably darker as light levels at night are much lower than light levels during the day (master of the obvious here! :slight_smile: ). And depending on the background against which foreground objects are viewed, there will be more or less detail (contrast), ranging from quite a bit (trees against a dark background, and before it gets completely dark) to none at all (trees silhouetted against the sky, and after it gets completely dark).

  2. The perceived hues in a scene shift as our eyes shift from using cones to using rods, with the shift becoming more extreme, the darker it gets (photopic, mesopic, scotopic: http://handprint.com/HP/WCL/color4.html#mesopiccolor). Greens shift towards blue-greens. Reds disappear. And the perceived saturation drops.

  3. Even though direct moonlight is the same color as direct sunlight, the colors we see in stripes of moonlight aren’t the same colors we see in stripes of late afternoon sunlight, because as the light levels drop, our eyes are more sensitive to blue wavelengths than to yellow or green or red wavelengths.

The RT CIECAM02 module really isn’t set up for making the above kinds of changes, at least not “automagically”. For example, if the user wants to actually change the “color of the light” illuminating the image, the only option is to go to “Preferences/Color Management” and change the output device white balance under the CIECAM02 settings, and then reload the image.

Also, there seems to be no way in RT to accomodate two different light sources in an image, or a way to affect different hue ranges differently (maybe the pipette? I didn’t try that). So “day into night” can’t be done just using the RT CIECAM02 module.

But the RT CIECAM02 module does have nice controls for modifying lightness/brightness/chroma/saturation/colorfulness/hue/contrast Q/contrast J. So I think the RT CIECAM02 module can be very useful for emulating the kinds of changes in how we perceive colors and contrast as the color of light changes, and as light levels rise or fall, even if this means making multiple exported images with various settings. And it’s also useful for fine-tuning shadow tonality. But this kind of editing is independent of making changes in a finished image for display on a given device under given viewing conditions.

(Desmis) #16


Thank you fot this very special usage of CIECAM :slight_smile:

(Elle Stone) #17

Hmm, I’m not sure that my use of CIECAM to make a night scene from a day scene is all that special. CIECAM is about changes in color appearance, and the way we perceive colors changes as the light level changes. The RT CIECAM02 Image Adjustment options seem well-suited for emulating such changes, but not until the Scene and Viewing Conditions are modified to not affect the image appearance all by themselves.

My apology for stating the obvious, but one thing that changes how we perceive colors is when viewing the same scene under different “colors of light”, which is addressed by chromatic adaptation. Currently the RT CIECAM02 chromatic adaptation code is specialized to handle one very specific instance of chromatic adaptation, which is how the colors need to change to make the colors “look the same” if the white point of the intended display device differs from the white point of the device on which the image is being edited.

But what if the user wants to change the “color of light” in the image itself as part of an editing workflow, completely apart from how the image will look as displayed on some hypothetical future display device?

I put an example of using the CIECAM02 module to “change the color of the light in the image” on my website, and my first question is does my procedure even make sense? And if not, why not? and is there a better way to use CIECAM02 to change the color of the light in the image?

I think the particular example I posted looks pretty good, but maybe this is by pure chance:

Using (misusing?) RawTherapee’s CIECAM02 to capture the color of the light

Here’s a photograph of a lamp lit only by the lamp’s tungsten bulb, shot raw, opened with RT, and custom white-balanced on the PVC plastic shown in the image, using “Colors/White Balance”:

My actual goal for the image wasn’t to “white balance away” the tungsten color of light, but instead keep the ight looking like tungsten light. A common approach to “keeping the colors” is to use Daylight white balance instead of custom white balancing on a neutral white or gray object. Daylight white balance produces the following, which compared to the actual “real life” lamp is too orange and too saturated:

Keeping the custom white balance and using the CIECAM02 module to chromatically adapt the color of the light back to Tungsten (assuming my procedure actually makes sense) produces this (imho nicer, and definitely much closer to reality) rendition of tungsten light:

It would be nice if instead of just “Tungsten”, there was an option to dial in specific Temperature/Tint combinations as real-life light sources seldom exactly match presets.

I want to experiment further with different scenes and different source and destination “colors of light”. But this is made a bit difficult because currently the destination “color of light” is limited to just a few options, and changing this color requires accessing the Color Management options and then reloading the image.

I did try changing the color of the light in the test image from tungsten to D65, but lacking a D65 light bulb for the lamp, I’m not sure how close the result might be to what would be seen in reality, and I wasn’t sure of what combination of CA models and display device color temperatures to use (I tried several other combinations, but the colors came out considerably more and probably too saturated):

It might be nice if the current RT CIECAM02 chromatic adaptation options were enhanced to include user control over the source and destination “color of light” - not just for an eventual display device that’s different from the display device used for editing - but also for changing colors in the actual image itself. I’ve had the relevant code files open in the geany code editor for the last week, trying to suss out the logic, but I’m not very good at reading c++ code.

(Sebastien Guyader) #18

Maybe it’s a dumb question, but wouldn’t it be simpler to make/use HaldCLUT’s for this type of color work?

(Desmis) #19


I’ll add in some times, 3 sliders : “Temperature”, “Tint”, and “mean luminance” of output device…It is obvious that I would remove these options settings :slight_smile:

(Andrew) #20

hi Elle, maybe another dumb question!, but couldn’t you have got what you wanted with the lampshade by adjusting the “main” White Balance temp. & tint to taste? And if this wasn’t quite enough then use further tools, including CIECAM, but also Lab to change the hue directly, or RGB Curves say?

(Elle Stone) #21

A CLUT allows to give a “look” to an image or a whole bunch of images. If you use someone else’s CLUT, then that’s simple. If you have to make your own, then making a CLUT only makes sense if you really do want to apply the same “look” to a bunch of images, because before you can make the CLUT, you already have to have an example image modified to have the desired look.

Even if CLUTs can adequately capture any given change in the color of the light, the color of the light illuminating a scene changes all the time. Even for a tungsten bulb, the actual color of the light depends on the wattage, how long the bulb has been used, whether you have the bulb hooked to a dimmer, what other light sources might be illuminating some or all of the scene, and a host of other factors.

In my example lamp photograph the lamp was indeed hooked to a dimmer, and there is almost no chance that that particular “color of the light” will ever be repeated even within the confines of my little “still life studio”.