Showing posts with label software. Show all posts
Showing posts with label software. Show all posts

Friday, July 27

Two-Color (Or One-Axis) Color Systems

RESEARCH INTO COLOR motion pictures started soon after cinematography itself was invented in the late 19th century. While color photography at that time was already well-established in the laboratory and by intrepid amateurs, cinema had its own problems, notably the need to project multiple frames per second in order to give the illusion of motion.

The main method of making color photographs was suggested in 1855 by the Scottish physicist James Clerk Maxwell. By exposing three photographic plates separately through red, green, and blue filters, and then projecting those images, overlapping, through the same filters, would then produce a color image on a screen. Or the same images could be printed on paper using various colored inks.

The main problem was determining how to do the same thing with cinematography. Any method devised would have to be visually impressive, relatively inexpensive, and would have to be extremely reliable, especially during projection at the theater. Using three cameras with three color filters was out of the question, due to parallax problems, and worse was the great expense and difficulty of aligning three separate projectors.

Compromises had to be made, and one such compromise was using only two colors: some color, perhaps, is better than no color. Film stock is transparent and has two sides, and many methods were devised so that one side would be sensitive to one range of colors, with the other side being sensitive to another range of colors. The film would be developed, producing an image on both sides, which were then dyed to the appropriate colors. The film could then be projected through standard projectors with no additional equipment needed. Surprisingly, very many films were created with the two-color method, starting in 1908, becoming common in the 1920s, and this was still used until the 1950s. But few of these color films remain with us today, and many of those survivors are now only available in monochrome versions specially made for early television.

While the two-color method died out in favor of three-color cinematography, by no means should we think that these kinds of methods are completely obsolete, being only temporary solutions limited to a particular place and time in history. Instead, I think that these methods, reinvented with digital technology, are interesting in their own right and can be used by contemporary photographers for artistic purpose. My related research on imitating Autochrome, an early color photographic process with a more limited color palette than is now standard, can be found here.


Consider this photograph taken in Forest Park, in Saint Louis, Missouri, during a ballon race:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - original

Many of the early two-color process films used green and red filters. My first naïve attempt at two-color photography was simply to eliminate the blue channel in Photoshop, by filling it with black:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - no blue channel

Instead of mainly red and green colors, we here have mainly yellow. As yellow is the opponent color to blue, and since we eliminated the blue color, we should expect to get lots of yellow. Oddly enough, my eye still sees some blue here when none exists, but is this simply because I know what the colors ought to be, or because some other subtle effect is happening? I do know that Edwin Land, the inventor of polarizing filters and Polaroid instant picture film, thought that he could get full-color images from only two color filters, although his research remains seemingly impossible and is controversial to this day, was never put into a commercial product, and I’ve never seen a convincing demonstration of it — but still I am not sure.

Now I can’t say that this yellow image simulates a two-color film process, for I can’t say that I’ve ever seen a two-color film. In a darkened theater, the eye’s own automatic white balance function would be active: but would the yellow colors appear to be closer to white? I have no way of verifying this. Now, normal attempts at white balancing this image in RGB — leaving us only green and red tones — is not possible, since we don’t have a blue channel.

Now, I can bring the white colors in the original scene back to neutral by adding a blue layer on top of this image in color mode and 50% opacity, but the shadows are then given a blue color, which is not what we want here.

Alternatively, I can use Photoshop’s Photo Filter function, which simulates the use of color filters placed in front of a camera lens while shooting. I must admit that I find this function to be rather mysterious, for as far as I can tell, it does things that cannot be reproduced by the use of curves and levels or any other type of processing in the RGB color space. Perhaps it moves the image into another color space, such as Lab, but I cannot verify this.

What I did with this image is use a Photo Filter layer, using the RGB primary blue color (0, 0, 255), at 100% Density, 50% opacity, and checked Preserve Luminosity. The image still had an overall color tone, but I was able to white balance it easily using Curves:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - red and green 2

This is almost precisely what I expected to get. Now what use is this kind of processing? I leave that up to you.

We can get two more variations of this method by blacking out the red or green channels, and using the Photo Filter with the color of whatever channel is eliminated, but the expected results we got with red-green colors are not duplicated:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - blue and green

Using only the blue and green channels does not give us a blue and green image, but rather green and violet. What is going on here? Clearly I don’t understand color vision as well as I’d like, nor do I understand the processing used by Photo Filter.

Likewise, using only the red and blue channels does not give us an image in those colors, but rather blue and yellow:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - red and blue

My apologies to the young ladies for the horrible skin tones on the last two images.

The Photo Filter function of Photoshop seems to be rather powerful, and I am convinced that it transcends the RGB color model, but it does not work in a manner that I consider predictable or in a way that I understand. Far more understandable is the Lab colorspace in Photoshop, which implements a color system based on studies of human color vision. See the article “Color Spaces, Part 4: Lab” for more information. Like RGB, Lab describes color with three numbers, but instead of specifying the amount of red, green, and blue light, it uses one number for lightness, and two others for specifying color.

The two Lab color axes are a, which specifies a range of colors going from a slightly bluish green to magenta, and b, which goes from a slightly orangish yellow through a sky blue color. These color pairs are opponent colors: if you would mix a negative ‘a’ color with a positive ‘a’ color of equal value, you should get a neutral gray.

RGB uses three fixed primary colors, and the specific primary colors used by any RGB color model is specified by the color standard used: sRGB uses primary colors that are closer together than does Adobe RGB. The choice of primary colors limits our color gamut. Lab, on the contrary, does not use primary colors, but instead the two color axes are theoretically unlimited, thereby allowing any color whatsoever to be represented.

Moving the image to Lab, and then by setting either the a or b channels to 50% Gray, we can quickly get a two-color (or alternatively, a one-axis) image. Here are the colors of the a channel:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - Lab a

In the photo above, the b channel is neutral, and this shows us a range of colors available in the a channel. If we neutralize the a channel instead, we get a different range of colors:

Great Forest Park Balloon Race (2011), in Saint Louis, Missouri, USA - balloon and two girls - Lab b

Good results, with an unchanged white balance, with very little effort. But what if we want to target colors other than the ones given us here? By using the Lab color space, we can have very precise control over color, as long as we are willing to do a lot of hard work, but the results are reliable and predictable. The following discussion includes extensive use of algebra, trigonometry, and geometry: proceed at your own risk.

Consider this photo, taken at a graduation ceremony last year, at the University of Missouri - Saint Louis:

UMSL graduation

Suppose we want to convert this to a two-color image, but we want to preserve the red color on the robes of the speaker. We can do this by algebraically transforming the Lab a and b coordinates.

Please consider this rather complicated diagram:

sRGB colors in Lab chart

Click on the image to examine this chart at its largest size.

This shows the relative locations of sRGB colors within the Lab color space. Although Lab can represent all visible colors, the sRGB space can only display about 35% of the color range visible to the human eye, but it closely models the gamut of colors displayable on ordinary computer screens or flat-panel televisions. The colored, irregular line shows the colors where one RGB color channel is equal to its maximum value of 255, another channel is 0, and where the third channel takes on all values — therefore this shows only the brightest, most saturated colors of sRGB. The Lab color space was designed to be fairly visually uniform — that is, equal changes of Lab coordinates will produce visually equal changes in color throughout the chart — whereas sRGB was not designed to be particularly uniform across all colors

Like standard artists’ color wheels, this image portrays colors arranged in a cyclical form — you can start at red, continuously change the hue, go through the set of common hues, and then return back to red where you started. But unlike the color wheels, this shows that the primary colors are perhaps not quite as absolute nor as uniformly spaced as we may like. (I created a color wheel specifically using the sRGB primary colors, which can be seen here.)

When editing in Lab in Photoshop, we can set either the a or b channels to 50% gray, which will eliminate that color axis from the image. The key to our processing is to rotate the colors in a way that will bring our key color to lay either on the a or b Lab axis, and then to eliminate the colors on the other axis by setting it to 50% gray. We then rotate the colors back to where they were before.

OK, back to the graduation sample image. The red value that I want to preserve has a value of R = 223, G = 51, and B = 44; the equivalent Lab color is L = 51, a = 65, and b = 48. I calculate that my color of red is located at an angle of about artangent(b/a) = or about 36 degrees above the a axis.

What we do next is rotate all of the colors around — by negative 36 degrees — so that my red is now on the a axis. We use the Greek letter theta (θ) as the symbol of the amount of rotation:

New a value = cosine(θ) x (old a value) - sine(θ) x (old b value)
New b value = sine(θ) x (old a value) + cosine(θ) x (old b value)

More information on this algebraic transformation can be found here.

For this example, where θ = −36 degrees, then sine(θ) = about -.59 and cosine(θ) = about .81. I move my image to the Lab color space, make a copy of the image, and then desaturate the copy, turning both the a and b channels to 50% gray. Using the Apply Image command in Photoshop, I’ll either add or subtract the a and b color channels of the old image to the channels of my new image. Here is an example of one of the Apply Image commands:

Sample Apply Image

This is a somewhat complicated procedure if you try to follow the steps in your head, but here is the result of the color rotation:

UMSL graduation  - rotated colors

Every color was rotated by the same amount in Lab, and the red color of the robe is now equal to a = 80 and b = 0, showing us that this color is now along the a axis.  Now since we are eliminating the b axis, there is no need to create a new rotated b, saving ourselves two Apply Image operations, but I thought you’d like to see all the colors here.

Now we can eliminate the b axis, and then rotate the colors by the same amount, but in the opposite direction:

UMSL graduation - preserved red color

Here we have the colors rotated back to where they used to be, and the red color is preserved, within the limits of rounding errors.  Here I did the same thing, but this time preserving the Ph.D. blue color on the robes of the seated scholars:

UMSL graduation - preserving PhD Blue

And for fun, I mixed these images together, using the “Blend If” sliders within the Layer Style box, preserving both the red and blue, but eliminating green altogether:

UMSL graduation - preserving red and  PhD Blue

Photoshop is a bit more powerful than we would expect. Direct algebraic manipulation of images is a powerful method; undoubtably similar techniques could be used with digital cinema for interesting special effects.

Saturday, May 12

Digital Forensics

HAS A PHOTO been severely altered? I’m sure you’ve seen examples of photo forgery lately in the news media. How exactly can you detect if a photograph is a composite of more than one original camera image? How can you tell if the clone tool has been used on an image, replacing scene detail at one part from another?

See the Digital Forensics webpage for original research by Hany Farid and his group at Dartmouth College.

Of particular interest is a large PDF file of lecture notes, which starts out with a number of famed doctored photographs from history, and then immediately jumps into complex mathematical examinations of digital images.

Wednesday, November 30

Photoshop Wishlist


  1. When I apply noise reduction in Photoshop — no matter what technique I use — the apparent saturation decreases. Why is this? How can this be avoided? I don’t want to merely add saturation back in, but avoid it. I’ve noticed the same thing with small-sensor digital cameras, those that do lots of noise reduction in-camera.
  2. Are there any good techniques to get rid of the brightly colored noise found along edges? This is due to demosaicing the Bayer array of the sensor. Eliminating this noise usually leads to desaturation of the good pixels.
  3. Photoshop does not resize images well, and often generates interference patterns. Lots of research has been done on these kinds of algorithms, and it would be good to see these better solutions in Photoshop. Also, fractal resizing has many benefits and would be valuable to have also.
  4. I’d like to be able to fully edit ICC profiles in Photoshop. For example, I have a profile that uses the GRACoL ink colors, but has other parameters I’d like to change. The Custom CMYK interface is rather lacking.
  5. When you use curves in RGB, you can either do it with the Normal blending mode, which typically causes an increase in saturation, or you can do it with Luminosity blending, which decreases saturation. How about a simple method which does neither? I just want the tonality to change, not the basic coloration. Click here to see how it is done.
  6. A solid method of adding local contrast. ‘HDR toning’ does this a bit, and a lot of other things at the same time too, making it less useful. ‘Clarity’ is pretty good, but tends to produce halos also. There are better methods.
  7. A ‘Vibrance’ tool for CMYK. This increases saturation without causing any channel to blow or plug.
  8. I’ve noticed that there is a distinction between chroma, colorfulness, and saturation; not really sure how or what Photoshop does. A solid colorimetric model would be useful.
  9. More color spaces. XYZ and xyY would be useful.
  10. Using Munsell colors in the color picker would be great, as well as better out-of-gamut warnings.
  11. Better statistical color tools. Something that can show all the colors in an image as a three-dimensional solid would be great.
Yeah, I know. All of this development is expensive, and it is easy to criticize!

Monday, November 28

Using ICC Profiles for Creative Color Control

Notice: the ICC profiles I link to in this article are now accessible again.



COLOR MANAGEMENT has become far easier since the introduction of standard ICC profiles, developed by the International Color Consortium, a group of various computer, digital camera, and imaging companies. ICC profiles describe the color handing characteristics of cameras, scanners, printers, and computer monitors, as well as allowing for uniform methods of converting the colors from one device to another. For example, ICC profiles are used to convert the colors captured by a camera to those colors available on a printer.

ICC profiles define a mapping from the typically limited color spaces of devices into a universal color space (which can describe all colors), such as CIELAB or CIEXYZ; from these universal spaces, the colors can then be mapped to an output device. As such, ICC profiles recognize limits of what is possible with any given device, and allows us to compare the capabilities of one device with another. If an output device, like a computer display or digital printer, cannot show particular colors, then the software will use the ICC profile to change the colors to the closest ones available (this will often cause the image to lose detail or saturation).

ICC profiles are also stored in image files, thereby interpreting the colors of the file, and these profiles are used during image editing. Typically, JPEG image files delivered by cameras are encoded into standard color spaces which are independent of the particular make and model of camera. The most common color spaces are sRGB and AdobeRGB; these provide a wide enough gamut of color for practical use, while being compact enough to produce reasonably small file sizes. ICC calls these "three component color encoding" standards. Using these standards are convenient because we can use JPEG or TIFF images from a wide variety of cameras without worrying about the specific characteristics of each. For example, an sRGB color value of (255, 0, 0) will describe the same bright red color, no matter where the image came from.  Some software, including web browsers, actually assume that all image files are encoded in the sRGB standard.

Click here for an overview of RGB color spaces.


I did not create this image. Click here for source and attribution. This shows the relative color gamuts of various RGB color profiles, as well as the color gamut of the Epson 2200 printer.

Each of the standard RGB ICC profiles defines three primary colors: particular shades of red, green, and blue. A narrow standard such as sRGB can describe about 35% of all colors, and so will have primary colors that aren't quite as bright, colorful, or saturated as the Wide Gamut RGB standard, which can describe about 77.6% of all colors. The ProPhoto standard is even bigger and has mathematical primaries that aren't even real colors.  However, be aware that most computer monitors and digital printers cannot display or print color much beyond the sRGB standard, and so sRGB is generally recommended for most uses on the Internet and for consumer-grade printing.

So ICC profiles have these uses:
  • Describing the color capability of a device.
  • A standard method of converting the colors from one device to another.
  • Describing the colors in an image file such as a digital photograph.
  • A widely accepted color standard for cross-platform image interchange.
May I also propose another use of ICC profiles?
  • Creative use. Artists can use ICC profiles to precisely manipulate and control the gamut of color in images.
In his book Professional Photoshop (5th Edition), Dan Margulis described the use of 'false profiles': using ICC profiles as an alternative method of image manipulation. He used this method to greatly brighten shadow detail without modifying the color: this is difficult to do with the standard Photoshop tools.





Estimating the colors of Autochrome

Now, while I made note of the false profile method, I rarely used it nor did I fully appreciate the wider potential of this method. But some months ago, I became interested in the old Autochrome Lumière method of color photography, released in the early years of the 20th century. These color slide plates produced somewhat muted colors, but the color palette produced was beautiful and lacked the often garish colors found in later slide films:

Couple


Couple, by Mrs. Benjamin F. Russell, ca. 1910; George Eastman House Collection. Source.

Woman in floral silk robe

Woman in floral silk robe, by Charles Spaeth, ca. 1915; George Eastman House Collection. Source.

Dancer wearing Egyptian-look costume with wings reaching to the floor

Dancer wearing Egyptian-look costume with wings reaching to the floor, unknown photographer, ca. 1915; George Eastman House Collection. Source.

I wanted to reproduce the colors produced by Autochrome, and thought that if I could determine the primary colors used by the Autochrome process, then I could create an ICC profile that could produce digital images with the approximate color gamut of Autochrome.

By collecting together a number of Autochrome images taken from the Internet, I was able to get a very rough idea of the range of colors found in the these images.

Now there are a lot of problems with my method:
  • Did Autochrome fall within the sRGB color gamut? Is the full gamut of color captured by these reproductions?
  • Are these direct photographs of Autochrome slides, or are these scans of printed reproductions?
  • Are these photos a representative sample of Autochrome?
  • What color of light was used when these slides were exposed? What color of light was used when these slides were digitally photographed? What white balance was used by the digital camera? How accurate is the camera color rendering?
  • How much have the color dyes faded with time? How much variation was there in the Autochrome process?
  • Autochrome is made up of small, visible colored grains; how do I reproduce the pointillist-like appearance of the method? [Update: see An Imitation of the Autochrome Lumière Process for one method.]
  • So forth and so on.
Now I can make some observations and educated guesses. Many Autochrome images on the Internet do appear to be faded, so I generally used the most saturated and brightest examples I could find. No image had colors that came close to any of the sRGB primaries, and so I thought that this method had some validity. Clearly, blues and cyans must be highly muted, while greens are somewhat better.  Red appears to be impossible to capture, while pink, peach, and some unsaturated yellows and yellow-greens are quite prominent. Orange often appears to be blown. Black and white are well-represented, although the white balance often seems to be off.

According to some authorities, the Autochrome process used orange, green, and violet primary colors; based on my inspection of these derivative images, I am convinced that orange and green are correct, but I'm not so sure about violet; it is only marginally violet at best, and unsaturated. Based on these primary colors, we ought to get pink, dull yellow, and dull cyan as secondary colors, and we do see these as prominent colors. Orange is often blown in these images (that is, it lacks detail and texture), something that I don't regularly see with any other saturated Autochrome color; this leads me to believe that the orange primary color is outside of the sRGB gamut. I also looked up the chemical dyes used in the Autochrome process, and those used can produce these primary colors.

Using the ImageJ software package, I was able to produce statistical plots of the colors found in the example Autochrome images.

Palace of Horticulture, Pan American Exposition

Palace of Horticulture, Pan American Exposition, unknown photographer, 1915; George Eastman House Collection. Source.

Here is a CIE xy chromaticity diagram of the colors in the image above:



The chromaticity diagram is a standard method of showing color gamut.  All of the lightest pixels of any given hue and saturation are plotted. The bright colorful pixels that form a triangle around this diagram are the primary, secondary, and tertiary colors of the sRGB color space: the primary colors are blue at the bottom left; green at top, and red on the right. See the chromaticity diagram, above on this page, which shows various standard color spaces.

Whenever we are mixing together three primary colors of light — additive color mixing — the chromaticity diagram will always be contained within a triangle, with the primaries being the corners of the triangle. Notice that the Autochrome colors also roughly form a triangle. We ought to expect that the corners of this Autochrome triangle are the primary colors of the Autochrome process.

Note that the blue corner of the Autochrome is well within sRGB, but the line between orange and green is right up against the sRGB gamut line. Now perhaps the Lumière brothers were precient way back in 1904, anticipating the ITU-R BT.709 standard of 1990 and choosing primary colors compatible with High Definition Television, or perhaps (more likely) the Autochrome gamut exceeds the sRGB standard. As it happens, I've found some Autochrome images stored in wider gamuts than sRGB, and indeed the orange color is beyond what sRGB can represent.

Now, if all my example Autochrome images had chromaticity diagrams bound by the same triangle, then my work would be done, and I could confidently establish the Autochrome primary colors. Rather, the chromaticity diagrams are variable:



Be aware that since the example Autochromes were digitally captured, the camera itself, plus any processing done on them could alter the final colors. The colors would be different if these were scans of printed Autochromes, or if the dyes faded, or if variable illumination was used to capture these images, or if these images were over or underexposed.

But in many cases, orange is likely blown, and blue is nowhere even close to the sRGB blue primary. These images do not approach pure green and they never show pure red. The Autochromes all generally fall within a particular limited range.

If we can assume that the colors used in Autochrome were uniform, then we can select primary colors that would pretty much give us an 'Autochrome look' to images. Be aware that it is not my intention to precisely characterize Autochrome, for that would be a large university- or industrial-level multidisciplinary research project, and while I would be happy to accept a grant for pursuing this research further, I really just want to make pretty pictures. I want to choose primary colors that are good enough, that give my images the right 'look’.

I went about estimating the Autochrome gamut by two methods. First, I got estimates from the color gamut diagrams, as seen above. Stacking the images in ImageJ, I was able to get both the total and the average gamuts using the "3D Project” tool:



Note that since these images were in the sRGB gamut, we have an outside triangle made up of accidental colors: this is the sRGB gamut triangle. These are due to calibration colors I inserted in the images, as well as artifacts due to low-quality JPEG compression and variation in digital capture. However, we can clearly see that the example Autochromes do not fill the sRGB color gamut, and likely exceed it along the red-green axis. Interestingly, note how the line between orange and green slopes in the bottom diagram: I suspect that orange is farther out of the sRGB gamut than the green primary, and that even possibly that the green primary is within sRGB.

To get a good Autochrome look, we probably need to go with a tighter triangle rather than a looser one; also, there is evidently very much variation in the digital captures of these images. Some images have strong blues, but most do not, even where we would expect to find them. I would think that in those cases, the blue colors come from the digital camera or post processing, and not from Autochrome.

I did an alternative method of estimating gamut. For each chromaticity diagram, I plotted the smallest area triangle that would contain all of the colors in the image. Then, I averaged together all of the gamut triangles, and took the resulting area that encompassed roughly 70% of the total gamut: it formed a very neat, regular triangle, which leads me to think I’m on the right track:



I then plotted these diagrams on a grid, allowing me to read the approximate chromaticity numbers for each primary color:




We can read the CIE xy numbers off of this grid, and create an ICC profile estimating the Autochrome gamut. Here I show two gamuts — both surrounded with red triangles — one shows my total estimated Autochrome gamut, which exceeds sRGB, and another one is bound to sRGB.

Please note that while I worked to estimate the Autochrome gamut, I did nothing to determine a white point for the medium, nor did I do any work to reproduce the pointillistic or impressionistic effect found in Autochrome slides due to their colored film grain, nor did I attempt to reproduce the tonal response or gamma of Autochrome. I only attempted to find the primary colors used in the process. [Update: see the article An Imitation of the Autochrome Lumière Process]




Using ICC profiles for creative color control

I created two ICC profiles. Click the following links to download:
You may also be interested in an older Autochrome estimate of mine. It is smaller and has a blue primary that is less violet than my newer one:
Put the files into whatever folder where Photoshop or your software accesses ICC profiles. On my Mac, it is ~/Library/ColorSync/Profiles.

The Autochrome.icc file uses Autochrome-like primary colors while remaining in the sRGB color gamut; you can use this to process images for display on the Internet. The "Autochrome Wide.icc" file has a gamut that exceeds sRGB; while the extra colors typically can’t be displayed on most monitors, they may be able to be printed, depending on the gamut of your printer: I wouldn’t suggest using the Wide gamut if you intend to display the images on the Internet.

Once the profile is in your system, you can edit image files with them. Using Photoshop, your image colors, no matter how much manipulation you do to them, will remain within the Autochrome gamut.

Please be aware that these ICC profiles are editing profiles, not device profiles, and are not what the ICC calls a "three component color encoding standard,” for it isn’t a standard at all, nor does it characterize any device. Only use this profile while editing your file, do not display files with these profiles on the Internet, and be careful when making prints from files with these profiles assigned. Far too many web browsers or consumer grade printers assume that image files are in the sRGB gamut.

Here is how these profiles are used:
  • In Photoshop, do either Edit->Convert to Profile or Edit->Assign Profile to use the Autochrome gamut. You may notice that your colors change either dramatically or slightly.
  • Edit your photo as you normally would edit it— adding curves, sharpening, saturation, vibrance, whatever you want. Your image will remain in the Autochrome gamut.
  • When you complete your edits, use Convert to Profile to put the image back into a standard color gamut: most typically, you’ll want to convert to sRGB for maximum compatibility. Again, this is an important step, for these ICC profiles are intended only for editing files, not for display.
  • The images may be a bit dark, and you may want to brighten them after the conversion to sRGB.
Please note that these ICC profiles only change the primary colors used. If your image lacks much color and is already within the Autochrome gamut, you may find that converting to Autochrome does little or nothing:



The image on the left is the original sRGB, the one on the right was Autochromed. Since the gamut of this image is rather small, there is little or no apparent change in the image. However, the following image shows a striking difference:



The weak Autochrome blue is quite evident, and it shifted to violet. Also, much of the detail on the tree on the right is now lost, due to the color being driven out of gamut.

Please note that we can either Convert or Assign a profile. This has a distinct difference:
  • Converting to a profile causes the pixels’ color values to change; if a color is out of the new profile’s gamut, it will be adjusted, often causing loss of texture and detail. Typically, any color that is already in the new profile’s gamut will not be changed visually, but the numbers used to describe that color will change. For example, the red sRGB primary color is (255,0,0), but the same shade of red in ProPhoto is (179,70,26).
  • Assigning a profile does nothing to the pixels, but they are interpreted according to the new profile. An sRGB value of (255,0,0) is interpreted as a the pure red primary color; after  assigning it to Autochrome, the value will still be (255,0,0), but instead will be interpreted as being the Autochrome primary orange color. This technique will change your colors, but is the quickest way to make an Autochromey-looking image. This also has the advantage of preserving all of the original detail and texture in your image.
Here are both methods:



Note that Assign kept the texture in the tree, but did change all of the colors, as well as making them less saturated. Be sure to convert your images back to sRGB when you are done processing them.

Using orange, green, and violet primary colors means our color wheel is rather unfamiliar:




The colors in this color space aren’t as brilliant as those found in sRGB, but you cannot get the same effect simply by desaturation. Any color space becomes quite distinctive when you push it to the limits, when you try to represent something that is near or exceeds the bounds of what is possible. If you push this color space too much, you will get large areas of orange and pink and violet, which is the Autochrome ‘look’.

However, I must admit that after playing with a number of images in this color space, I think that I made it too broad, and the primary ‘blue’ color too violet. I’m not sure as yet. I think that I may prefer my Old Autochrome ICC profile.




The sCMY colorspace

The attempt to replicate the Autochrome color space was an interesting exercise, and led me to consider limited color spaces in general, ones which would give photographers and graphic artists a new way of controlling the use of color. After all, when you have an ICC profile fixed to a particular palette of colors, the use of color is strictly controlled: you can’t go beyond the fixed limits.



The sCMYcolorspace uses dull cyan, magenta, and yellow primaries — dimmer tones, but of the same hue and saturaton as the sRGB secondary colors. Since this is an additive color space, the secondary colors are brighter than the primaries, so this does not work the same way as does the subtractive CMYK color space used in commercial printer. However, the color channels do have similarities.

In sCMY, the red channel is cyan; the green channel magenta; and the blue channel yellow: the opponents of the sRGB primary colors. And so, the green channel is black where we would expect to see lots of green ink if we were to print the image, and it is white where we would not expect to see any green printed.



This colorspace is unique in that there are no pure saturated red, green, or blue colors whatsoever; we do see pale tints of these at best.

How useful is this colorspace? For general use, not very. However, if there is a need or desire to limit the colors used, it can be interesting.

Due to the inverse quality of this colorspace, we cannot assign sCMY to an image and expect it to look anything close to being natural; instead, you typically want to convert to this profile before editing.

You can download sCMY by clicking here.

This exercise in editing color spaces can be explored much farther by the artful selection of primary colors, or alternatively, selecting bright secondary colors and deriving the primary colors from them.

UPDATE: I’ve also come up with a method to simulate the dark tonality and grain of Autochrome; see the article, An Imitation of the Autochrome Lumière Process.

Friday, October 14

Color Spaces, Part 3: HSB and HSL

IGNORE THIS ARTICLE: the information presented here is problematic, difficult to apply in Photoshop, is error prone, and obsolete. Do not read any farther. This information is of no importance to photographers.


OK, not really. This article is about color systems that ought to be useful, that ought to be implemented — somehow — in Photoshop, but they still have plenty of traps for the unwary.

Artists, unlike those who have an affinity for mathematics, may find the RGB color system a pain. They perhaps object to the idea of reducing such a subjective concept as color to mere numbers, or perhaps they object to the unintuitive process of mixing the colors together in RGB. Photoshop is such a pain. It must have been invented by nerds.

For example, the RGB color for a particular tone of orange is R=180, G=95, B=6. But this is ridiculous; orange, a mixture of red and green? And with some blue thrown in also? No, that's wrong. Orange is a mixture of red and yellow, and there ain't no blue it it at all: but for sure that dim tone of orange has some black in it. And what's with these RGB values going from 0 to 255??? That number 255 makes no sense at all. Now, if we have to use numbers (and why can't we use good names for colors instead?), then why not use something more understandable like 0% to 100%?

Also, it seems that some particularly pure colors are missing from RGB. Tyrian purple, intense electric cyan colors, and rich, deep tones are nowhere to be found.

A painter would rather describe color in ways other than RGB.  Here are some artists' color terms:

Hue is the basic quality of a color: is the color basically red, orange, yellow, chartreuse, green, aqua, blue, violet, or magenta? These hues are arranged in a circle around a color wheel, which shows how these colors relate to each other, and also how new colors can be obtained by mixing other colors. Now there is some controversy as to what precise set of colors ought to be used to obtain a minimal palette: some say that the three primary colors (red, yellow, and blue) is the minimum number of colors for a basic full-color palette; although white, black, or both are sometimes added to the mix, depending on whether the artist is using paint or watercolor. Other artists say that six colors (plus black and/or white) reproduces nearly the full range of color. Since these colors can mix together to produce nearly all known colors, any extra colors in the palette are simply a convenience to the artist; they aren't strictly needed. But no matter what color system is used, mixing together adjacent colors on the color wheel will produce novel colors, while mixing opposite colors together will give a grayish, blackish, or muddy tone.

Tints are pastel colors, made by mixing a color with white.

Shades are dark colors, made by mixing a color with black.

Brightness, value, or intensity tells us how close a color is in luminous quality to either white or black, or how bright a color is compared to the brightest available version of that color. Aqua is a brighter version of teal. Azure, dark midnight blue, and Dodger blue are basically only different in brightness.

Tones are colors that are mixed with both black and white (or gray) paint. These colors are muted, toned-down versions of the base colors.

Saturation, chroma, or colorfulness is how pure a particular color is. Tones, shades, and tints are less saturated than pure hues. Slate gray is less saturated than azure. Carmine is more saturated than copper rose, even though they are approximately the same hue and brightness.

Other qualities include transparency, fluorescence, glossiness, and so forth,


A good, artistic color system will take these usages into consideration. As it so happens, there does exist the HSB (Hue, Saturation, Brightness) color system, and it is implemented (albeit poorly) in Photoshop. This color system works in a more artistic manner than RGB.

Instead of three numbers for the red, green, and blue channels, HSB provides alternative numbering:

Hue specifies the kind of color, and it follows the arrangement of colors in a color circle. The assignment of colors is thus:

Red = 0°
Yellow = 60°
Green = 120°
Cyan = 180°
Blue = 240°
Magenta = 300°
Red = 360°, which is the same thing as 0°.

Hue


Brightness tells us how bright a color is, compared to the brightest, most saturated value of the color, and brightness goes from 0% to 100%. Anything with a brightness of 0% will be black, while 100% brightness gives us the most saturated bright color available. All the colors in the wheel above have 100% brightness.

Hue versus brightness

In this image, hue goes from 0 degrees on the left, to 360 degrees on the right. Brightness goes from 0% on the bottom, to 100% on the top. But note that HSB assigns 100% brightness in a way that isn't uniform; some colors are much brighter — visually — than others. 100% yellow is much brighter than 100% bright blue.

But note that brightness seems to act like a shade, where you mix a particular color of paint with black. The brightness value of 80% then is like a mixture of 80% color and 20% black, while 0% brightness uses 100% black paint.

Saturation tells us how pure or intense is a particular color. Saturation tells us how far a color is from neutral.

Hue versus saturation

Hue goes from 0 degrees on the left, to 360 degrees on the right. Saturation goes from 0% on the bottom, to 100% on the top. As saturation goes to 0%, the colors go to the same pure gray color.

Saturation seems to act something like a tone and shade combined. First you mix together the pure color and white paint: for example, 40% saturation would mix 40% color paint with 60% white. Then you mix the resulting color with black in the amount specified by its brightness.

Here we mix together brightness and saturation with pure red:

Brightness versus saturation

Brightness goes from 0% on the left to 100% on the right, while saturation goes from 0% on the bottom to 100% on top. Hue is fixed to zero degrees. This image shows the following characteristics:
  • Pure red is in the upper right hand corner.
  • Pure white is in the lower right hand corner.
  • Pure grays are along the bottom.
  • Pure shades of red are along the top.
  • Pure tints of red are along the right hand side.
  • Pure black is found along the entire left side.
Photoshop offers HSB as an option when specifying and measuring colors. The HSB selector is circled below in red:

Color Picker

The color selector square on the left of this shows us all possible hues with all saturations at a fixed brightness. The slider to its right can adjust for the brightness, keeping saturation and hue fixed.

The HSB system is useful because it works somewhat like an artist mixing bright primary colors with black and white. It also presents a natural ordering of color as is seen in the spectrum and color wheel.

Note that brightness, as defined by the HSB color system, is defined according to whatever color you happen to be using, and so 100% brightness gives us the pure color (whenever saturation is 100% also).

The HSB system is also called HSV, with V=Value.

An alternative system, HSL (Hue, Saturation, and Lightness) retains the H and S dimensions but substitutes Lightness that gives us white whenever it is 100%. For example, here is hue plotted against lightness:

Hue versus Lightness

Hue goes from 0 degrees on the left to 360 degrees on the right, while lightness goes from 0% on the bottom to 100% on the top. Pure saturated colors are found at 50% lightness. Adjusting lightness is like tinting a color when greater than 50%, and shading a color when less than 50%.

Plotting lightness versus saturation is this:

Lightness versus saturation

Lightness goes from 0% on the right to 100% on the left. Saturation goes from 0% on the bottom to 100% on the top. Shades and tints of red are along the top edge of the image, with pure red being in the middle of the top edge. Pure white is along the right hand side, pure black along the left edge, and tones of gray are along the bottom.

Photoshop allows us to select colors based on HSB, but we cannot edit images in that colorspace as we can when we convert an image to the Lab or CMYK colorspaces. But there is an optional component in Photoshop (available on the original disk) that we can install to get the HSB and HSL channels. From the Filters menu item we select Others and then HSB/HSL to get this dialog box:

HSB-HSL Parameters

Please note that after conversion, the image actually remains in the RGB colorspace. Since Photoshop really doesn't support HSB images, you have to remember what color space you converted to in order to go back.

Image - RGB and HSB

The original image is on top, and the ‘converted’ image is on the bottom. Although you can edit your photos after the conversion, you can't see what the final result is like until you do the reverse conversion.

This simply changes the appearance of the color channels:

Image with HSB channels

From top to bottom:
  • Red channel = Hue
  • Green = Saturation
  • Blue = Brightness or Lightness
As we could expect, the brightness channel looks fairly normal and it has the least noise of the three channels. From information theory we could predict that much more real information is contained in Brightness, while the noisy saturation channel tells us that the information there is minimal and unreliable.

When I originally discovered this colorspace, I thought it could be very useful. For example, back in the days before Photoshop had a ‘Vibrance’ function, I wanted to selectively saturate an image so as not to overexpose or underexpose any of the color channels; this is something that the standard Saturation tool can do all too well. I thought that the saturation channel of HSB could be used as a mask.

But black can have any saturation at all according to HSB. This is counter-intuitive. Just look at the sky in the photo: it is very dark, it ought to have low saturation, but the noisy saturation pattern shows us otherwise.

I had the bright idea that HSB could be useful for noise reduction. Blurring the color channels is a popular and accepted method for reducing chroma noise, so why can’t I do it in HSB?

Colorchecker with blurred hue channel

I just had to do this once to see that it was a big FAIL. I didn’t think about what I was doing. It is interesting to see that HSB thinks that the black color of the chart has a green hue, which is seen bleeding over the colors.

I’ve been unable to come up with any good use for the HSB channels. Whatever I wanted to do, there was a better way of doing it in another colorspace.

There are a number of other technical reasons why HSB and HSL are bad colorspaces:
  • HSB and HSL are not absolute, but rather depend on what color space you are working in, like sRGB or Adobe RGB. An HSB number like 0° Hue, 100% Saturation, 100% Brightness does not name a concrete color, but rather the primary red color of whatever colorspace you are working in.
  • Look at the images above which show hue. Note that the colors do not flow smoothly into each other, as we would like. Yellow, cyan, and magenta appear to be ‘spikes’, with same phenomena  to a lesser degree happening to red, green, and blue.  As it happens, the colors are distributed linearly between the primary and secondary colors, and do not flow in a more visually-uniform manner.
  • Take a look at the image of hue versus saturation above. At 100% saturation, the areas of red, green and blue tones appear to be much broader than the secondary colors.  But go down the image towards lower saturation: the secondary tones yellow, cyan, and magenta now appear to be much broader than the primary colors. It appears that saturation shifts colors. This color shift is also apparent in the hue versus lightness image. [Update: it appears that some of these artifacts are due to my monitor’s calibration.]
  • Black can have any hue and any saturation. Attempts to edit an HSB image (as seen in the Colorchecker image above) can lead to strange artifacts whenever black is involved. 
  • Brightness and luminance do not describe the relative brightness of each color. Pure blue is considered to be just as bright as yellow, even though visually it appears to have a tenth of the absolute brightness.
  • Saturation is problematic in HSL. A pale light yellow is said to have the same saturation as does a rich green color.
HSB and HSL, along with another colorspace called HSI, were invented in the 1970s as a way of selecting colors on a computer in a more artistic manner than RGB. However, these are simplistic mathematical transformations of RGB color spaces — and are not based on the properties of human color vision — and so have problems as seen above. More information can be found here.

Cynthia Brewer of Pennsylvania State University wrote:
Computer science offers a few poorer cousins to these perceptual spaces that may also turn up in your software interface, such as HSV and HLS. They are easy mathematical transformations of RGB, and they seem to be perceptual systems because they make use of the hue-lightness/value-saturation terminology. But take a close look; don’t be fooled. Perceptual color dimensions are poorly scaled by the color specifications that are provided in these and some other systems. For example, saturation and lightness are confounded, so a saturation scale may also contain a wide range of lightnesses (for example, it may progress from white to green which is a combination of both lightness and saturation). Likewise, hue and lightness are confounded so, for example, a saturated yellow and saturated blue may be designated as the same ‘lightness’ but have wide differences in perceived lightness. These flaws make the systems difficult to use to control the look of a color scheme in a systematic manner. If much tweaking is required to achieve the desired effect, the system offers little benefit over grappling with raw specifications in RGB or CMY.
RGB and CMYK are output-based color systems, which are closely related to actual, physical output devices such as computer monitors and printers. RGB also closely reflects how cameras capture color information. Editing in these color spaces, while not necessarily intuitive, is recommended so as to take full advantage of the output media. But as we have seen, there is very much value in using a more intuitive color model that reflects human vision. The Lab colorspace (fully supported by Photoshop) is particularly useful and is based on human vision.

HSB and HSL are problematic color spaces that do not live up to their promise. They were invented by computer scientists who needed a simple color system that worked well with the low-performance computer hardware available at that time. HSB (also called HSV) was invented by Alvy Ray Smith, who later co-founded the Pixar animation studio. HSL was invented by George H. Joblove (who subsequently did animation in the films Terminator 2, Spider-Man 3, the Chronicles of Narnia, and many others) and Donald Greenberg (who previously worked on the Gateway Arch; he subsequently won many awards in the computer graphics field, and has trained many of the prominent animators working today.) Both HSB and HSL were first published in the August 1978 volume of SIGGRAPH's Computer Graphics newsletter. As these men all had quite remarkable careers, we perhaps should not judge them so harshly because of their color system inventions.

The problems found in HSB and HSL are also found in more serious color standards. The Natural Color System (NCS), which is the official color system of Sweden, Norway and Spain, is based on the notions of blackness, saturation, and hue based on opponent colors, But it has the defect of assigning the same brightness to its base colors of red, green, yellow, and blue. Also, NCS had the flaw of assuming that red and green are opponent colors, which is not true. NCS is based on the philosophical theory of phenomenology — and not directly on human psychology — which may have led the designers to make some mistakes.

Three numbers suffice to describe color, and so we can build three-demensional color models. The RGB system forces all colors into a cube, while HSB and HSL force all colors into a cylinder. But as we see, these systems are not visually uniform and have plenty of problems.

Mathematics is good only insofar as it reflects reality. Bright, saturated yellow is brighter than bright, saturated blue. Magenta is the opponent color to green. Black and white have no hue and no saturation. A mathematical model of color ought to consider these facts and model them well. It appears that the best color model today is the Munsell color system, which arranges the colors in a visually uniform, but irregular solid. It does not force colors into a regular geometric solid such as a cube or cylinder. Albert Munsell was an artist and art teacher, and he wanted to be able to communicate color to his students in a more uniform and logical fashion than just using color names, and he began by organizing his colors by visual appearance. Originally, he thought that he could organize all the colors into a sphere, but eventually he found out that an irregular shape better reflected the visual ordering of the colors. Here is an example of slice taken through the Munsell color solid:
Munsell value (vertical) and chroma (horizontal); hue 5Y and 5PB

12 10 8 6 4 2 0 2 4 6 8 10 12
10






255 255 255






9
228 228 250

232 232 232

243 227 207

250 227 178
8
190 201 239

200 200 222

203 203 203

215 200 181

221 200 154

227 200 126

233 199 97

237 199 63
7
142 176 241

154 175 225

164 175 210

173 174 195

179 179 179

188 173 155

194 173 128

200 173 101

205 172 72

210 172 29
6
79 150 244

101 150 227

116 149 213

128 149 198

138 148 182

146 148 168

150 150 150

161 147 129

167 147 103

173 146 75

178 146 42
5
46 124 214

72 123 199

89 123 185

101 123 171

111 122 156

120 122 142

124 124 124

134 121 103

141 121 77

146 120 48

150 119 9
4
38 97 172

59 97 158

74 97 144

85 96 130

93 96 116

97 97 97

108 96 77

114 95 52

119 94 25
3
26 72 133

45 72 120

58 72 106

67 72 92

70 70 70

81 71 55

87 70 33
2
20 49 93

35 49 79

44 49 66

48 48 48

57 48 34

63 47 6
1 5PB
13 28 56

23 28 45

28 28 28

37 27 9
5Y
0
0 0 0
[source]

This is a visually-uniform system; and there ought to be a visually equal difference between adjoining color patches. (However, note that the presence of the gray background causes the appearance of some irregularity in this image.) Because the system is visually uniform, the outline of the colors are not uniform. Saturated blues will always be darker than saturated yellows, as is shown here.

In the Munsell system, there is no upper limit to the chroma, or the brightness and saturation of color. Bright new pigments or fluorescent dyes can be added to the outside edge of the Munsell solid as needed.


I started this article with a warning that the information contained here was problematic, error-prone, and obsolete. The HSB and HSL color systems, although supported somewhat in Photoshop, are problematic color systems at best.

There is still a need for an artistic, more natural system of color in our editing software; but unfortunately HSB is not the solution. The commercial product HVC Color Composer allows the user to select color based on the Munsell color system. What makes this system novel is that it will automatically limit colors based on color gamut and human vision; it is also visually uniform. Unfortunately, since it is neither available on OS X Lion or on Photoshop CS5, I cannot evaluate the product here.

The best free alternative is to use the Lab color space found in Photoshop. Since this system arranges colors into a cube, it still has a component of unreality. Using Lab, it is very easy to drive a color out of gamut or out of the bounds of human vision. I also suspect that Lab has a slight color shift for dark colors. But Lab is otherwise very useful and logical, and I use it quite often.

For more information on color spaces, see my articles:

Color Spaces, Part 1: RGB
An RGB Quiz
Color Spaces, Part 2: CMYK
Part Two of "Color Spaces, Part 2: CMYK”
A CMYK Quiz
Color Spaces, Part 4: Lab

Thursday, September 15

White Balance, Part 2: The Gray World Assumption and the Retinex Theory

WHITE BALANCE is one of the most important functions of digital color photography. Understanding a little bit of theory about this function could improve your photography.

Very many beginning photographers (and I was certainly one of them) are quite disappointed with the quality of their images. Although they may find it hard to put into words just what precisely is wrong with their images, bad color or a color cast may be a significant problem. When I learned about white balance and how to correct for it, I immediately thought that my photos looked much better.



Bad versus better white balance, among other things. Saint Vincent de Paul Chapel, in Shrewsbury, Missouri.

Clearly, the color of light is often variable, and the color my camera captures is usually somewhat different than what I see in real life. However, if I am careful to set the white balance, then typically my colors look much better under most circumstances.

There are some principles that we ought to keep in mind:
  • Our eyes do white balancing naturally. This leads to color constancy, where particular shades of color appear to be subjectively similar under a wide variety of objectively different lighting conditions.
  • White balance in photography corrects for extreme changes in the color of light; it is not a slight adjustment.
  • For the best results, we ought to do white balancing early in the photographic process.
  • We cannot rely on the camera or software automatic white balance function to give good results.
White balance and the process of adjusting color is also called gray balance, neutral balance, color balance or color correction. In cinematography and video, the equivalent process is called color grading, color painting, color timing, or digital grading. Color film is manufactured to produce good colors for only specific light sources; changing film stock or using color filters is typically needed to compensate for lighting changes.

Our eyes have built-in white balancing which strongly subtracts out the color of the lighting. While this mechanism also works when we are looking at photographs, the fact that most photos are relatively tiny and low-contrast means that our eyes will adjust to the room condition more than our images. This means that we have to color-correct our photos to subtract out the color casts due to the color of light at the time of capture.

For an overview, see my article, White Balance, Part 1.

Please recall that digital cameras have a fixed white balance, a balance that is not particularly optimized for any typical lighting condition. For most cameras, this white balance is biased towards green, and is deficient in red and blue; most particularly, cameras are highly deficient in capturing blue light under incandescent lighting.

For example, here is an image taken with my digital camera using its native white balance:

Buildings in Clayton, camera native white balance

Buildings in downtown Clayton, Missouri. Image presented with the camera’s native white balance.

I processed this image in Raw Photo Processor, and used the UniWB setting which does not adjust the white balance. Notice how green the image appears! White balance is an intrinsic operation of digital cameras: some sort of white balance is always applied to your image, and be aware that your camera may not always give you a good balance.

Now, I recommend setting white balance at the time of capture, either using one of the white balance presets, or manually setting it using a neutral gray card. Automatic white balance usually works rather well in daylight but can be problematic especially under incandescent lighting, on overcast days, around sunset, or in mixed lighting conditions. Setting your white balance at capture time also means that you can get better exposure and can rely more on your camera's histograms. Setting white balance at capture time is less critical when you shoot RAW, but it is extremely important to get right if you shoot JPEGs.

Although it is hard to give good numbers, I do think that the majority of photos — especially editorial photos produced for publication — ought to have a good white balance. An object that is objectively white, gray, or black in the scene ought to be objectively represented in your image with RGB values that are objectively white, gray, or black; that is, all RGB numbers are equal on a neutral subject. Click here for an overview of the RGB color system. Even if you need to reproduce a color cast, for example the color of sunset or candlelight, only slight color casts are usually desirable, otherwise you risk washing out the detail in your image, making it look flatter without texture. Knowing how to make a good white balance will also give you the ability to precisely add tones to your image for an effect.

Knowing some theory can help your photography. Understanding how white balance works will help you to make better photographs. Being able to control your color will allow you to make a photo look as you want it to look.

We first need to understand that white balance is usually a very simple arithmetic adjustment, with little to no higher math. Typically all of the red values are multiplied by a fixed factor, and the same goes for all the blue values. Now these numbers will vary by lighting conditions, the camera make and model, and there are other things that happen behind the scenes in your camera or RAW processor. But this multiplication is the basic correction for white balance. Many digital cameras, in daylight, will multiply the red channel by about 2, and the blue channel by about 1.5; under incandescent lighting, red might not be adjusted much at all, but the blue channel might be amplified 2.5 times, increasing noise greatly.

For example, here is the familiar X-Rite Colorchecker target, photographed in bright daylight:

Converting from intrinsic white balance to daylight

On top is the camera native white balance, and on the bottom is the white balanced version, created from the native white balance using the curves tool:

Converting from intrinsic white balance to daylight - curves

Photoshop's simple Curves or Levels tools are sufficient for doing a white balance, although there are other clever tricks you can do for a better job. But ultimately, white balance is linear: the adjustment is the same for all of the pixels in an image.

Now sometimes you don't get good white balance for whatever reason, and you have to adjust it after the fact on the computer. On the photo above, I know that the squares on the top row of the X-Rite target are approximately neutral, and I could have adjusted my curve much more precisely than shown here. But what if you take a photo and have no idea what white balance settings you should use? What if you don't have any particular patches in your photo which are guaranteed to be neutral? Also, how do cameras perform the automatic white balance?

For a long time, when I was puzzling about how a camera does white balance (and why it fails), I assumed that the camera simply measured the overall color cast and then corrected for it. Clearly, when I took photos under incandescent lighting, the colors tend towards yellow; subtracting out that yellow (I thought) ought to produce a nicely white balanced image. Likewise, photos taken in the shade tend to look blue, and so this blue ought to be removed. Photos taken under fluorescent lighting are often too green.

The Gray World Assumption is a white balance method that assumes that your scene, on average, is a neutral gray.

Imagine you are given this JPEG image, and your task is to correct the white balance:

Trees -- bad white balance

Old sink-hole iron mine, at Maramec Springs Park.

This appears to have an overall yellowish-green color cast.

Gray World assumes that all the colors in an image ought to average out to a neutral gray: for every blue there is a yellow, for every red there is a cyan, and for all greens there are magentas.  For this image, using Photoshop's Average function, we get:

Trees -- bad white balance average color

Here is how you can use the Gray World Assumption in Photoshop:
  • Duplicate the image layer
  • Do a Filter-Blur-Average on the top layer.
  • Place an eyedropper anywhere on the image.
  • Create a Curves layer on top.
Your layers should look like this:

Trees -- bad white balance Adjustments 1

Now adjust the curves until all the RGB values are equal. You may have to change the Curves blending mode to Color, to avoid blowing a channel, but this makes adjusting curves a bit less straight-forward.

Trees -- bad white balance Adjustments 2

You should see that the image now looks perfectly gray — if not, then your monitor needs calibrating.

Remove the gray layer, and you have a white balanced image:

Trees -- Gray World Assumption white balance

This process worked pretty well for this image. But certainly we cannot hope that this will work for all images; what if the subject is brightly colored?

Snow scene - extreme white balance

A view of my parents’ back yard, in the snow.

The Gray World is not a good assumption for this image; it simply has too much blue and too little red to reconstruct a plausible image. Now it so happens that I captured this image in RAW, but had inadvertently set the white balance to incandescent lighting. While this wrong white balance is what is presented here, the RAW processor can be adjusted to use a better balance. This is a strong reason to shoot RAW instead of the compressed 8-bit JPEG format.

But not everyone shoots RAW, nor does every camera offer it, nor can we always have access to the original RAW image file. We can have some other assumptions besides the Gray World. First, it would seem that the very brightest highlights in an image might reflect the color of the light source in a rather pure way. Likewise, the very darkest shadows in an image could be assumed to be pure black.

The Retinex Theory was developed by Edwin H. Land, the inventor of Polaroid cameras and polarizing filters. Since humans can identify colors under a wide range of lighting conditions, Land theorized that the very brightest patches of light are used by human vision to determine the color of the light, to automatically compensate for this color cast. Like Land, we can identify the brightest patches of the red, green, and blue channels in an image, and adjust our colors based on these.

Dinosaur unadjusted

A dinosaur exhibit at the Saint Louis Science Center.  This image has an orange color cast.

Using the Retinex Theory, we examine the red, green, and blue channels separately and put eyedroppers on the places where each of these channels is brightest.

Dinosaur detail

On each color channel, I used the Threshold tool to determine the brightest patches. Dropper #1 is on the brightest part of the red channel, and dropper #2 has the brightest part of both the green and blue channels. I used 3x3 droppers, but you can experiment with using larger droppers, or single pixel droppers.

Dionsaur adjustments

I adjusted the image with Curves so that the brightest parts of the red, green, and blue channels were all equal. The result isn't bad:

Dinosaur adjusted with Retinex

We can extend the Retinex Theory to not only identify the brightest colors, but also the darkest. We make all the bright colors equally bright, and all the dark colors equally dark. And while we are at it, why don't we force the very brightest colors to their maximum value, and why don't we adjust the darkest colors to their minimum value? This will expand the dynamic range of our image, which is usually considered good practice for commercial photography.

[However, please note that some artists state that we ought to retain color in deep shadow, since this more closely models what we actually see, and it is also pleasing. In this case, we ought not adjust the darkest shadows to be a perfect black color. A problem with this is that the RGB color models allocate very few bits to this kind of shadow detail; on the contrary, CMYK and other printer profiles, since they use black ink in combination with colors, can in fact nicely show textured shadows with color casts.]

Forcing the brightest pixels of the red, green, and blue channels to a value of 255, and the darkest pixels of each channel to 0 happens to be precisely what Photoshop's Auto Levels does:

Trees with Auto Levels

Trees in fog, illumined by the rising sun, on the Meramec River near Eureka, Missouri.

The bottom image was corrected with Auto Levels. While a color cast may or may not be desirable with this particular image, Auto Levels often does a surprisingly good job of automatic white balance.  Here are the settings I used:

Auto Levels

Selecting “Enhance Per Channel Contrast” will identify the brightest and darkest bits of each color channel, (like we did with the dinosaur) and adjust the image from there. This option will produce the strongest correction. “Find Dark and Light Colors” will rather select the brightest and darkest pixels as a basis for adjustment — this is similar to the Perfect Reflector (or White World Assumption) algorithm for automatic white balance, which assumes that the very brightest patch in an image reflects the color of the light source, and so forces it to be white.

The Photoshop menu items “Auto Tone” “Auto Contrast” and “Auto Color” are all shortcuts to various settings in this window.

Be aware that Retinex or Auto Levels will not work properly, or at all, if any of your color channels are over or underexposed. Auto Levels, using the settings above, does nothing to this image:

Church - uncorrected

Saint Patrick Church, in Rolla, Missouri.

Here the camera's white balance was set to Auto, and it failed to adjust for the color of the light. I suspect that my Nikon may use some sort of Retinex algorithm, although that can't be the whole story since overexposed daylight images usually appear to have good white balance. Typically, when I shoot indoors, I do a manual white balance in the camera.

I attempted to produce a good manual white balance of this photo. Alas, after examining this photo, I conclude that the light shining on the altar at center is undoubtably incandescent, while the light fixtures hanging from the ceiling have fluorescent lamps. The corrected result shows green and magenta color casts all over the image, which looks rather worse than the yellow image shown above. If I can, I turn off fluorescent lights before photography: blue and yellow color casts look natural, while magenta and green color casts look sickly. If I were seriously interested in improving this photo, I'd put down some masking and color-correct the altar area separately from the rest of the nave. Mixed lighting will harm every automatic white balance, and will make life difficult for a conscientious color retoucher.

There are white balance algorithms that attempt to combine aspects of the Gray World Assumption and Retinex Theory. The major problem with these is that these two algorithms are not compatible. Remember that white balance is ultimately a linear transformation of color data. A combined approach will generate curves that are not linear, and so are ultimately inaccurate white balances. Take a look at the Auto Color Correction Options shown above; the “Snap Neutral Midtones” feature (from what I've been told) will blend in a little bit of Gray World with the other adjustments. But this rarely gives good white balance and often looks a bit odd because the colors may shift with brightness.

If we have a RAW image file with strong red and green channels, and a weak blue channel, then we can probably guess that it was taken under incandescent lighting; likewise, if we have strong blue and green channels but weak red, then we can conclude that the image was mostly likely taken in open shade, while a strong green but weak red and blue channels is probably daylight. If you have looked at tens of thousands of images you start seeing obvious patterns.

These Photoshop histograms show data from two photographs of the same object, taken under widely different lighting:

Histograms - Incandescent versus overcast

These show the channel structures of two RAW images, uncorrected for white balance: the top is from an image taken under incandescent lighting (which is deficient in blue light), while the bottom image was taken outside during an overcast day (and so is deficient in red light). Recall that the histograms show the darkest bits on the left side, and the brightest on the right. Looking at the histograms we can conclude that the top image has an orange or yellow cast, while the bottom image has a cyan color cast.

This observation gives us another method of white balance, called Color by Correlation, which makes assumptions about typical light sources. It attempts to determine if a particular image was plausibly taken under a wide variety of light sources. It is highly implausible that the first histogram above was taken in the shade or on an overcast day, but if we assume that we have incandescent lighting, that histogram becomes quite likely. We can even analyze individual colors: can we be really confident that a bright blue object (according to the RAW channels) can be found under incandescent lighting? Unless it is a light source within the image, bright blue is impossible. If we go over a broad range of colors and ignore outliers in our data, then we can estimate the quality of light in an image.

This type of method can confidently estimate a range of lighting conditions that could plausibly produce a given image. But unfortunately, we cannot be satisfied by a range of plausible white balances, for an in-camera automatic white balance algorithm must produce one and only one result. Color by Correlation, by design, uses only a discrete number of specific light sources, and not the full range of all theoretically possible lights. The Law of Parsimony or Occam's Razor may lead a software designer to severely limit the choices for light sources: after all, nobody uses green lights to illuminate the inside of a home, so why even consider it? Right? And so I would expect that this method will select a white balance based on one of the limited number of light sources used in its model.

I suspect that Adobe Camera RAW's Auto White Balance feature uses a variant of Color by Correlation: very often it will select a white balance equal to one of the standard white balance options, most notably Incandescent. Considering the wide range of color adjustments you can make in ACR, it seems highly unlikely that it will so often choose a standard preset so precisely if it weren't using this method. ACR Auto will never produce a horribly bad white balance — as we so often see in the other methods described earlier — but it very often produces a mediocre white balance. On the other hand, Retinex Theory, when it works at all, it works very well, but when it works poorly it is bad, while the Gray World Assumption can give us nearly anything from OK to horrid.

There are other white balance algorithms, but I don't know enough about them to comment, and I've come up with a few automatic methods which tend to generate results ranging from OK to dismal. From what I've read, Color by Correlation is the best automatic method, but you can do better yourself.

I hope this exercise demonstrates that we cannot rely on automatic white balance. According to a major scholarly article, “Automatic white balance is an under-determined problem and thus impossible to solve in the most general case.” There are technical methods that could improve automatic white balance significantly, but they would require modifications to existing camera designs.

Manual white balance is something photographers ought to consider when doing their best work, as well as being aware of the quality of light in their image. As I mentioned earlier, even though precise white balance is typically needed for commercial work, an understanding of the principles involved can help those who want to move away from neutral balance for artistic purposes.

Here are some hints for getting excellent colors and white balance:
  • Have uniform lighting on your subject. Use a good incandescent light source like the sun or bright incandescent light bulbs. Avoid fluorescent lights, and especially avoid mixing incandescent and fluorescent lights together. The newer light emitting diode (LED) lighting also have poor spectra for photography.
  • You get the best color and best white balance when you use your camera's native ISO; this is usually, but not always the lowest setting.
  • When shooting outdoors in the sunshine, you can hardly go wrong if you set your camera to its fixed Daylight white balance, and this will retain the pleasing warmth of late afternoon light. When indoors, using the Incandescent or Tungsten setting may work well; but be aware that gas discharge lights (which include fluorescent lamps and sodium vapor lamps used for street lighting) will generally make your photos look poor and they may not be fully correctable.
  • Do a white balance as early in your workflow as possible. The best time is when you take the photo. Do a manual white balance at your subject, with the white balance card facing the camera.
  • Photograph a white balance target within your scene to double-check your settings.
  • If you don't have a white balance target, examine the scene closely for objects that appear to be neutral in color; you can use these for white balance in the camera or later in post-processing. Be aware that white paper or fabrics may have ultraviolet dyes to brighten them, and so this may throw off your white balance.
  • Color calibration will not only get your colors looking right, but this will also increase the accuracy of your white balance.
  • The best white balance after the fact is done using the camera's original RAW channels. RAW conversion software may use these channels directly for white balance.
  • If you have a lot of time on your hands and are mathematically proficient, you can create your own color transfer function to convert your camera's RAW channels into a precisely color-calibrated image for specific lighting conditions. This would also facilitate accurate white balances. That is what I did in the Colorchecker photo above. See the article Examples of Color Mixing.
  • If you color-correct in Photoshop, use 16 bits and a broad color space like ProPhoto or Wide Gamut RGB, even if you have to convert to a smaller color space later.
  • If you have three objectively neutral colors in your image: one dark, one light, and one medium, you can edit your curves to make a very precise and uniform white balance. However, if your curves are very curvy instead of being straight, then be aware that your neutral colors may not be illuminated by a uniform color of light, or your colors may not be as neutral as you think.
  • When adjusting white balance using Curves, you typically only need to modify the red and blue channels.
  • The Lab color space at first seems to be a good space to do color correction, since it separates luminosity information from color. However, it is not precisely uniform: doing white balance adjustments in Lab will throw severe color casts into the shadows.
  • Another bad space for doing white balance is the standard sRGB color gamut. Editing in 8 bits also will give you more problems. But this is very common; many cameras only produce 8-bit, sRGB images, and some software packages can only process 8 bits per color channel.
  • The best book for learning color correction is Dan Margulis' Professional Photoshop. Although this book is slightly dated and notoriously difficult, if you diligently work through it several times you will learn a lot. Dan isn't always right, but this book is definitely worth the effort: you will thoroughly learn how to best use the basic tools of Photoshop.
  • Examine the separate color channels of your image to see if there is sufficient color information to do a good correction. If all three channels exhibit good detail and have a wide range of tones that do not go all the way to black and to white, then you likely can do an excellent white balance. If one of your color channels is nearly all black or white over large areas then there is little hope for a good white balance; we see this in the snow picture above, where the red channel is largely black. Sometimes it is possible to reconstruct parts of a channel by using data from other parts of the image and by careful use of the painting tools.
  • Don't rely on your eyes. Your monitor may be defective, your eyes may be tired, and changes in room lighting can cause variation between images. Rather, measure objects in your image that are objectively neutral in real life and then modify these colors so that they are objectively neutral in your color space (typically when R=G=B). Even if you want an overall color cast, precisely add this color in reference to an objectively neutral object; this is essential when you have to put the same color cast on a number of different images. By using these objective techniques, someone who has color-deficient vision or who has a terrible monitor or bad working conditions ought to be able to do excellent color corrections.
  • Rely on your eyes. Don't trust any automatic method of white balance: if you think the colors are bad, then they most likely are bad. Also, ‘perfect’ white balance, for some images, simply looks wrong. In dim lighting, cameras will not produce images that have tonalities that we see with our eyes, due to the Purkinje Effect. An overall color cast is perfectly acceptable or even desirable for many images.
  • If a large neutral gray object filling your screen does not appear to be neutral gray to your eyes, then you probably ought to calibrate your monitor. Mac computers have a built-in calibration that often works rather well, and there are hardware devices that can do a more thorough job. However, calibrating your images is more important than calibrating your monitor, especially if you are going to share your photos on the Internet or submit the photos for printed publication.
Related Posts Plugin for WordPress, Blogger...