A side benefit was the ability to see the relationships between the color numbers in various color modes, for a given sample color. It crystallizes the obvious fact that each color space has its own color limits (gamut) irrespective of the minimum and maximum numbers. And it illustrates the fact that the meanings of terms like hue, saturation, and lightness varies with each color space.
I also use this to validate and explore target values for my camera calibration scripts.
Since this script is entirely menu based, it can only be used with Adobe Photoshop CS2 or later. To use this, simply install two files in the Photoshop scripts folder (described later). Then start it via the Photoshop File: Scripts: menu.
At startup a small temporary image is created and discarded simply to determine the current Adobe Default RGB working space profile.
Next, a new image document will be created to preview color changes. This will be dismissed when the script finishes. It will be used to display the currently selected color. Or, you can provide your own preview image as discussed later. This allows you to see any color shifts created by different color values, illuminants, color profiles, gamut limits, and such.
Then a menu similar to the following is displayed.
The input fields are populated with Lab default values based on a standard red color. The remaining defaults will be based on the RGB profile shown.
The first area in the menu deals with White Point or Reference White options. This may be selected from standard CIE CCTs A, B, C, D50, D55, D65, D75, F2, F7, F8, F11, or E. These are based on the standardized Coordinated Color Temperature of a light source.
The Kelvin text box next to this allows you to enter the CCT in Kelvin degrees, 1000 to 25000. If you enter a valid Kelvin number, the CIE CCT list box will be ignored. The White Point adjustments will based on the Kelvin temperature in degrees. Values from 4000K to 25000K are based on simple calculations. Values from 1000K to 3999K will be based on a table lookup. This allows input in the Tungsten range. This table may take a few seconds to initialize the first time it is referenced.
The current white point XYZ and xy adjustment values are shown next, based on the currently selected CCT or Kelvin color temperature. These are the default values that will be used for chromatic adaptations as needed.
Four sub panels for entering color values in xyY, XYZ, Lab, or RGB mode follow, along with one to show color differences. Each panel has its own calculate (C) button. Changes in these panels are propagated up and down when a calculate button is pressed. If any input fields have been changed an * will appear next to the respective calculate button. It will remain until one of the calculate buttons has been pressed.
There are three input boxes for the respective xyY values and a calculate button. This button will calculate xyY to XYZ to Lab to RGB.
The xyY values are also shown as LCh(xy). Technically, this is not a CIE color space. It is my own construct, but it helps to show the location of the current color in the xyY chromacity coordinates. By using some standard CIE tables, this also shows the dominant spectral wavelength (or complimentary wavelength) that represents the current color. The chromacity value is also shown as saturation based on the xyY locus of the standard observer. This is the edge of the chromacity diagram. The hue displayed is the hue angle of the color on the chromacity diagram.
If any of the xyY values are out of range, E! will appear next to the calculate button. If the xy values lie outside the chromacity locus, G! will appear indicating a gamut problem. Some folks call these imaginary colors.
There are three input boxes for the respective XYZ values and a calculate button. This button will calculate XYZ to xyY and XYZ to Lab to RGB.
The 2° checkbox allows you to choose between the 2° and 10° standard observers for the LCh(xy) calculations. No other calculations are based on spectral data and no CIE color matching functions are used. So this will only affect the corresponding LCh(xy) display. Adobe always assumes the 2° observer.
The Scale XYZ checkbox allows the input and display to be scaled 0 to 100 instead of 0 to 1. Different vendors use different paradigms for the XYZ values.
The XYZ values are also shown as Luv and LCh(uv). The hue displayed is the hue angle of the color on the Luv chromacity diagram.
If any of the XYZ values are out of range, E! will appear next to the calculate button.
The Adapt WP button will convert the currently displayed XYZ values from the current white point to the New CCT shown to the right. The CA Method list box allows you to select from the common chromatic adaptation methods, Bradford, Von Kries, and XYZ Scaling. This updates the XYZ values only. Subsequent calculations are left to the user.
There are three input boxes for the respective Lab values and a calculate button. This button will calculate Lab to RGB and Lab to XYZ to xyY.
The Lab values are also displayed as 16-bit integers. They should correspond to the Photoshop Info Panel 16-bit Info displays. Be aware of the fact that Photoshop actually uses what they call quasi 15-bit integers that range from 0 to +32768.
The Lab values are also shown as LCh(ab). The hue displayed is the hue angle of the color on the Lab chromacity diagram. Since the Lab chromacity diagram is a polar axis based on four colors, the hue angle will be very different than in the other color spaces. And the saturation is based on the size and shape of this diagram, so it will also be very different than the other color modes. Lab mode can also include many imaginary (or out of gamut) colors. These are numerically valid Lab values that result in invalid XYZ values or xyY values that exceed the range of the standard observer.
In addition, due to the (artificial) -128 and +127 limits in the ab values, there are some valid XYZ colors that are invalid in Lab mode. These ab limits are imposed so that Lab values can be stored in 8-bit integer image files.
The ICC D50 check box determines the reference white in Lab mode. When checked, Lab calculations are based on adaptation to the D50 illuminant as defined by the ICC. If this is unchecked, Lab values are based on transformation from the XYZ white point as defined by the CIE and the ISO. Note that Adobe always assumes that all Lab values are based on the ICC D50 standard. All Adobe profile conversions are based on that assumption.
Note that unlike XYZ, the white point in Lab is fixed (0,0). This is because Lab mode uses a polar coordinate system. In addition, technically, the Lab chromacity is based on scaling from CIE illuminant E (equal energy). Thus, the source illuminant (reference white) must be known for transforms to other color spaces (XYZ or RGB).
If any of the Lab values are out of range, E! will appear next to the calculate button.
This panel simply displays the color difference between the current Lab values and a reference color. Use the Set button to set a reference color from the current Lab values. Then, as the Lab values are changed or re-calculated, the Delta E 2000 color difference will be shown. A DE2K value of 1.0 means that a color difference should be observable by a standard observer, after viewing for at least one second.
There are three input boxes for the respective RGB values and a calculate button. This button will calculate RGB to Lab to XYZ to xyY.
The RGB values are also displayed as 16-bit integers. They should correspond to the Photoshop Info Panel 16-bit Info displays. Again, be aware of the fact that Photoshop actually uses what they call quasi 15-bit integers that range from 0 to +32768.
Then the RGB values shown as HSB. This gives you an indication of the hue, saturation, and brightness of the current color. The HSB calculations are not considered very scientific, so some color experts disdain them. But graphic artists are very familiar with them. Just be aware that due to RGB gamma, gamut and such, the values will change if the RGB profile changes and they may not correlate with the CIE values for the same color.
If any of the RGB values are out of range, E! will appear next to the calculate button. If a color is out of gamut in this color space, G! will appear here. Any non-neutral color that contains 0 or 255 is considered to be out of gamut.
The RGB ICC Profile list box can select Adobe RGB (1998), ProPhoto RGB, sRGB IEC61966-2.1, or ColorMatch RGB. This will be used for the Adobe transforms between CIELAB and RGB color modes. The first profile in the list will always be your initial Adobe default profile based on your Photoshop color preferences. The Adobe default will be restored when the script ends.
This is dynamically changed by the script because Adobe bases many of its internal calculations on the current default profile instead of the current image profile. If you select a new profile, both the default and image profiles will be changed.
At startup, if there is an open image with a saved selection, its profile will be used and added to the list if necessary. This allows testing with vendor supplied printer and camera profiles.
The Precision entry field is used to round display values. The valid range is 3 to 12 digits. This has no effect on the precision of the internal calculations or user input. All internal calculations are done in floating point with precision at about 14 digits.
The Paint RGB check box will use the current RGB values for painting any image colors. If it is unchecked, the current Lab values will be used. The resulting color should be the same in either case.
The Show diagnostic alerts check box will enable an alert when any calculations result in numbers that are out of range. An "E!" is also displayed in the panel to the right of any numbers that are in error or out of range. This will also enable a user dialog whenever the Adobe default profile is changed. This allows you to review and change other options such as conversion intent.
The CIE xyY and CIE XYZ values are essentially the same and the calculations are pretty straightforward. Essentially the Y values are luminosity with different scaling. The xy and XZ values are the chromacity (color) coordinates encoded differently. The xyY values are based on chromacity coordinates and the XYZ values are based on spectral color stimulus. The xyY values are what are typically graphed on a chromacity diagram.
The transformation between CIE XYZ and CIE Lab is a bit more complicated. In Lab the L channel is luminosity, but it does not map directly to the Y value in XYZ. Y relates to luminous power but L relates to the density of white with some adjustments for visual response. Like the xy or XZ values, the ab values define chromacity. The XYZ white point is needed for this transformation in either direction. It is also know as the Lab reference white. The same principles relate to RGB color conversions.
With two possible standards or paradigms, it is possible for chaos to reign. The CIE and ISO assume that the Lab reference white is the same as the XYZ white point. The ICC and Adobe assume that the Lab reference white has always been adapted to D50. This may be accomplished by either chromatic adaptation or spectral adaptation. Spectral adaptation can only be done with spectral data, such as from a photo spectrometer. It is not always clear which paradigm is being followed, so caveat emptor.
Also, the SolidColor object depends on your current Adobe default working RGB profile. So it is changed when you select a new target ICC Profile. That is why at startup the script will determine you current setting and restore it when the script finishes. Be aware that some extremely unlikely errors may prevent it from being restored.
If you have an open document you can make and save a named selection that this script can use to paint updated color values. Within this selection, you can add eyedropper watch points that will show in the Info pallet. I use four watch points, Lab and RGB and 8-bit and 16-bit for each. Each time a new calculation is performed, the watch points will update.
Then use the 16-bit display to compare the calculated values against the actual image values in the Photoshop Info pallet. You must save the selection (an alpha channel) for this to be activated. The name is unimportant. You will then see a confirmation message at startup asking if you want to use this document and selection for painting updates.
This technique can also be used to test with a vendor ICC profile that would not be in the default list.
In some cases, this can also be used to validate the Lab reference white for the target colors shown in a vendor datasheet. Simply enter the Lab values and change the reference white until you get a match with the vendor supplied XYZ values. It can also be used to validate the correlation between Lab and RGB values. Have fun.
Another use is to explore what is happening with near gamut or out of gamut colors based on a particular printer profile. Simply open a document prepared in the printer profile (described above). Then enter the base color values you want to explore in the appropriate panel and recalculate. You will be able to see the color visually and the numbers in XYZ, Lab, and RGB. Problems such as gamut in any of these will be shown. You can switch back to your default working space and see the visual changes along with the corresponding numeric changes. This is similar to the concept of proofing colors in Adobe before printing. However it targets a particular suspected problem color instead of the image in its entirety.
I have used it to debunk the myth that changes to the Lab luminosity channel have no effect on color. Although the ab values (chromacity) in Lab mode do not change, the color (saturation and hue) does change in the other color modes. In small doses, the luminosity changes are not destructive. But in strong doses, the effects can be very significant. All things in moderation.
Similar techniques can be employed to identify and explore the imaginary colors in Lab and XYZ. That is, colors that are numerically valid but that do not represent a valid visible spectrum color. These will display as something on your screen, but color conversions have been compromised. For an example, start with the script's default red, Lab [42, 53, 28]. Change the Lab L value from 42 to 12 and then from 42 to 72 and observe the visual color and the numbers. Try this with Adobe RGB, a printer profile, and with Pro Photo RGB.
I created these scripts so that I might be able to incorporate more light sources in my raw image calibration and checking scripts. The text reports aid this greatly. To finish this I will need to borrow, rent, or buy a colorimeter or other measurement device. This has to be able to read reflected light from various sources. It is not the type used for typical monitor or printer calibration. If you know where I can do this at a reasonable cost, please contact me. It also provided me with a practical self-education on more of the color science calculations and a better understanding of how they are applied.
I hope these can help you understand the various forms of color numbers, color differences, and the color relationships. If you have suggestions for other uses or new features, please let me know.
I have researched the formulas extensively and validated the results against other color calculators such as Bruce Lindbloom's. I have confidence in the answers. The script can be downloaded in a ZIP file from here: ColorCalculator.zip Simply extract and copy the JSX files to your Photoshop CS installation folder then under ../Presets/Scripts. Then restart Photoshop to make it available from the File: Scripts menu.
This script is provided as shareware with no warranty. My testing was all with PS CS2 and CS3. You are free to use and modify it. If you feel obliged to pay something, make a contribution to your favorite charity.
This was last updated on September 25, 2006.
I hope you also gained some new insight from this article. If you have any comments, or suggestions, I would welcome your input. Please send me an Email.
Rags Int., Inc.
204 Trailwood Drive
Euless, TX 76039
January 14, 2006
September 25, 2007
This page last updated on: Wednesday October 03 2007
You are visitor number 56,184 since 08/04/06