More Focus Stacking

This little fellow is a hatchling turtle carved from Phytelephas “nut”, which looks a great deal like ivory. Detail I want to capture includes the small spots on the inside of the egg shell (behind the turtle). He’s a trick to photograph because all three of his dimensions are about equal in extent. That means he takes a big depth of field to shoot if you are going to fill the frame. I put my macro lens on, and the best I can do is the next shot, which was taken just to show the scale of the turtle.

The shot with the coin was taken at f/22, in crummy light; the exposure was about 2.5 seconds at ISO 200. The depth of field is still not as large as I want, and in the original there is substantial blur—which is probably diffraction. The focus stacking result is much, much more pleasing. I used the brilliant combineZM software (free as in GPL) to assemble about 20 shots into the main picture. A sample of those shots is shown below. You can see the position change, which was due to my unstable platform. combineZM is doing an amazing job of aligning the images.

As you can see from the focus range on frame 9, I provided too frames for the first half of this set. I probably should have shot close to 40 images. I also think it would be worthwhile to be very careful in moving the inter-frame focal point. Finally, the defocus on the near components of frame 20 looks bad—it looks extremely non-Gaussian, and I suspect that is responsible for some of the artifacts I had to work hard to suppress. I hope to get my hands on a Nikkor AF-S 105 mm f/2.8 micro relatively soon, perhaps that will help…

With respect to reducing artifacts, the leader shot is actually a composite of two products from combineZM. Overall, the best shot came from the “Do Stack” macro; however, the edge of the shell directly above the turtle was blurry (circled below). The “Soft Stack” macro produced a crisp shell above the turtle; however there were odd looking artifacts (inset) all over the image. The final result I got by masking in just the sharp parts of the shell from the “Soft Stack” macro while leaving almost all of the image as the result of the “Do Stack” macro.

Color (White) Balance

A friend of mine suggested my first two posts were pretty difficult to follow. To address that, this is the first in a series of posts which will ramble on about other interesting digital photography topics in a more accessible way. Feedback is appreciated.

There are lots and lots of tutorials on the net, so consider this a teaser—if you want details our good friends at Google will help.

In my order of importance, the technical aspects of taking a good photograph are

  1. Focus-if your subject is out of focus you’re stuck. There is no way to post-process to fix bad focus.
  2. Framing-cutting someone’s face off is also uncorrectable. Almost as bad is getting too much of everything else and not enough of your subject.
  3. Exposure-though as long as you don’t underexpose or overexpose too much you can do some recovery in the computer. Flash can make this very challenging.
  4. White balance-people should not look greener, yellower, or redder than they naturally are. Often this is correctable in the computer, but it is really fiddly—getting it right in-camera can save a lot of time.

The other stuff is compositional—are your subjects’ smiling, is motion blur minimal, are flash shadows tolerable, and is the view interesting. Good compositional skills are what separate a really good photographer from, well, me. This article is about white balance. Just because it is number four on the list doesn’t mean it isn’t important. To get a feeling for just how important it is, look at the collage below—which shows the same picture rendered with a variety of white balance settings.

These pictures were shot inside my light box (a bucket) under natural light. In the custom setting I manually evaluated the white balance. I shot this picture in raw, and then applied the color corrections in Paint Shop Pro. This might mean the color casts are the opposite of what would be seen if I shot the picture in the claimed light with the wrong setting on the camera.

Color can be subtle, because although it is absolute in objects it is not absolute in perception—the proportion of colors an object reflects doesn’t change, but the apparent color certainly does. Our eyes and brains do an amazing job of figuring out what the true colors of objects are, even though the light can vary from, for example, the yellow of a sodium vapor lamp to the cool white tones of a fluorescent tube. Our brains can do this by processing cues from the environment around the things we’re looking at.

Cameras, however, capture a scene. The environment surrounding the scene is not recorded by the camera. Because of that we draw the color cues from the area we are in when we are viewing the picture, not the area the scene was in. In order for the colors in a picture to look good to us the camera (or post-processing) must render the neutral colors in the scene as neutral colors in the image. In other words, the camera has to remove the effects of weird lighting.

Generally your camera does an amazing job of compensating for the color cast of the scene lighting. With white balance set to “auto” most cameras, including my Nikon D40, Canon S2IS, Canon G3, and Canon SD100IS all do a fantastic job—usually. They don’t always, though.

I speculate that a camera’s white balance compensation works by having the camera select the most neutral portion of the image and assuming it is completely neutral, to first approximation. That is, the camera assumes any color cast in the most neutral parts of the image is due to color cast in the lighting, and it compensates it out. Experience has told me that camera processing is somewhat more complex; however, I find this model works well at predicting when I will need to be careful with colors.

When I’m shooting a scene with nothing neutral in it, I’m sometimes better off with a manual white balance setting. This happens a lot when I put my baby on a dark blanket—which I do sometimes to get a good contrast.

Shooting for Good White Balance

The best choice about nine of ten times is to leave your camera in auto. If you fiddle with white balance settings it is just a matter of time before you leave it in some weird manual mode just when Baby is doing something cute. And then Baby is forever remembered doing something cute while being green.

Sometimes, though, you want perfection. Then the best bet is to set your white balance to “custom”. Custom settings work by having the photographer place a neutral object at the site of the subject, and then taking a picture (in the custom evaluation mode). You can buy special neutral cards to carry, but I’ve had excellent success with just a plain sheet of paper—which I carry folded up in my camera bag.

Be creative in a pinch. I once saw a TV cameraman pull one leg up and bend the camera down to his ankle to set the white balance on his sock.

Two Lights

It happens pretty often that I have two sources of light. Most commonly there is an ambient light, fluorescent in the kitchen, natural near the windows, tungsten/incandescent in the dining room, and the flash. These sources sometimes come from different directions and light different parts of the scene. On the left of the picture below you can see the color comes from the room light, and on the right it comes from the refrigerator light. This picture doesn’t suffer for it, since we would see it as entirely normal. If the color came instead from the flash, however, this effect would be very awkward looking.

I don’t have a way to fix this kind of error, except to avoid it in the first place. If you have time to set up you can put compensating gels over the flash (which works really, really well). Alternatively, you can try to find an orientation that minimized the effect. If you’re me, and you’re photographing people, you just live with the bad color balance. Except for portraits, and then I use gels, manually set the white balance, and maybe shoot raw just in case. Raw is, generally, more correctable.

Focus Stacking, First Stumbling Steps

Edit: 2009/01/30, evening.  After much searching I relocated an incredible site I had encountered before.  Charles Krebs’ work is really, really, incredible.  I was motivated to explore focus stacking after seeing image 29 in gallery 8, which I believe was produced with stacking.  Dig around his page, it is really awesome.

— Original —

I ran into the technique of focus stacking not long ago, and have been itching to try it since. I haven’t found good subjects, but I took a first stab this morning. The results of some of workers with this technique are absolutely mind-blowing. For some of my favorite work on the net, see http://www.janrik.net/insects/ExtendedDOF/. My example is of a small natural turquoise from a local mine. I used very poor stabilization, and I believe that has resulted in the artifacts at the far edge of the stacked frame. Nevertheless, this is very promising. Now if I can just find some interesting subjects.

My shooting setup for this, by the way, is crapulent to high orders. I use a bucket on a trashcan in the sun as a sort of lightbox, and a precarious tripod to shoot. The tripod was the source of my instability issues, but the trashcan certainly didn’t help. The bucket is not quite as good as the Lambertian integrating sphere I’d like, but it is rather more affordable.

Color Management – Reprise

I noticed that what I included in my post Introducing… does not look the same on my monitor as it does on my friends’ monitors. While I expected some of that, I observed that the effects of interest were not at all visible, particularly the posterization. To solve that, here’s a quick comparison, done by taking a photograph of my monitor. In the left photo I have color management on, but the mode is set to “display”. The right photo is set to “proof” mode, with the output device emulating the Costco glossy prints. See Dry Creek Photo for a variety of lab profiles.

The Color of Software

Philosophy of Use

This article is rather long.  Please scan ahead to the pictures to see where we are going, then come back and slog through the details.

The basic tasks I’ve needed to perform on digital photos since my first digital camera (a Canon G3, may it rest in peace) are:

  • orientation flipping
  • cropping
  • contrast adjustment
  • white balance correction or adjustment
  • straightening
  • communication to friends, family, work peers (by email or Web host)
  • printing, for albums, sharing, my lab notebook, or display

For several years I resisted photo annotation tools, which let you add text tags or captions to pictures, because the annotations were stored in proprietary non-portable databases. Image metadata formats, particularly IPTC, can carry captions, tags, and useful context details. Now that IPTC is widely supported, the picture files can carry this metadata without external databases. It is a compelling feature.

I used to organize my pictures in date folders, typically the date of transfer from the camera. All the pictures I shot on Christmas vacation ’07-’08 might get uploaded on January 3, 2008. The pictures would be stored in a directory with a name like 20080103, a format I love because it lists chronologically when sorted alphabetically. If I needed to edit pictures I would process them in GIMP, which has supported cropping, flipping, contrast, and straightening reasonably well for many years. Modified versions of the picture would be saved with some indecipherable name, like dc021_m2_sm.jpg, which might stand for “2nd modification, resized smaller (sm) for upload to web”. As a process, this was the pits.

In the last year my needs have grown, due largely to lessons from shooting with a digital SLR.

Shooting Raw

I’ll forego jokes about naked photographers. I started looking at more advanced editing software because some prints I ordered had dreadful color issues. I had the idea that the color problems might have been caused by some contrast stretching I performed in Picasa, or even that the image exceeded the dynamic range of the camera. Dynamic range issues in a camera can be treated three ways.

  • At the shoot, if saturation is the issue, then underexposing a little can improve the shot. If the scene is very high dynamic range, then the dark areas may be clipped on the low-exposure side. Even if they’re not clipped, the signal-to-noise ratio in the darker areas may result in noisy regions of the photo. Noise removal software can sometimes help, but I regularly shoot conditions where there is clear loss.
  • Shooting camera raw preserves the full dynamic range of the camera’s sensor, which might be 12 bits per channel instead of the 8 bits per channel available in a JPEG file. Postprocessing the raw file could potentially allow level compression to provide a better JPEG than the camera’s processing.
  • Bracketing exposure and then combining in software can effectively enhance the dynamic range substantially. Some packages allow combining bracketed shots to get enhanced dynamic range. Normally I can’t shoot with brackets since my subjects are frenetic, so bracketed-shot combining is more of theoretical interest than practical.

This implies a few requirements for photo-editing software. First, it must be able to work well with raw images. In particular, I must be able to apply “levels” functions or “curves” functions to images containing the full raw dynamic range. In other words, those functions must work on 16 bit per channel images. Secondly, raw import of my camera’s format must be supported. Thirdly, combining bracketed images should be supported—though this is not a strong requirement.

Postprocessing raw files is tricky. You really don’t need an entire lossless file at 16 bits per channel for cropping, rotating, touchups, or most editing. However, for adjusting levels, contrast, or colors a full 16 bits per channel is a good thing—especially if you have a picture with really dark shadows and really bright highlights. Your tools must also be able to read your camera’s raw file format—for my ancient camera this is easy, but people with newer cameras sometimes discover that their files don’t import.

It turns out that my print issues had nothing to do with poor editing or limited dynamic range of the picture, and everything to do with color management. More on that later.

Tools

Consider that you might solve all your problems with photo management by acquiring software. Here are three approaches that might seem reasonable.

Free

For advanced editing use GIMP, which is very capable editing software. For downloading from the camera, managing photo collections and albums, uploading to the web or printers, and emailing Picasa is really very good. You might even consider just using GIMP for editing. Newer operating systems provide sorting and searching of EXIF data.

Cheap

For well under $100 you could get Adobe’s Photoshop Elements or Corel’s Paint Shop Pro. These include picture management systems, sophisticated editing capabilities, and some limited uploading or emailing capabilities.

Expensive

For $250 to $300 you could buy Adobe’s Photoshop Lightroom, which is an extremely sophisticated software package. I suspect it has the same uploading and emailing capabilities as Elements. Of course, Lightroom costs nearly as much as a new Nikon 35 mm lens.

Really Expensive

For something over $650 you can get what would seem to be the acme of photo editing tools, Adobe Photoshop CS4. I didn’t even bother demoing this, so I can’t comment on its photo management or distribution capabilities.

I compared some of the preceding applications for my specific interests. What will work for you depends a great deal on what you want to do. My baseline before getting interested in raw image processing was Picasa and GIMP. The rest of this document looks at some of the capabilities I consider important for some of the packages I just listed. To be fair, I’ve spent enough on camera equipment this year that $200 software package looks really profligate—so my emphasis is on free or cheap options.

The simple truth is that I love Picasa for almost everything. Here’s why:

Nuisance

To my stark staring amazement, PSE7 actually pops up little bubbles containing advertisements while you’re trying to work. I don’t know what is required to turn this “feature” off, but to get this in purchased software is intrusive, irritating, and offensive. Be prepared for an astonishing level of rage if you use this software.

Email

For email I use Google’s gmail, and Picasa’s email button works flawlessly with gmail. PSE7, PSP, and Picasa all support email through MAPI clients like Microsoft Outlook or Exchange. I have earned a burning hatred of Outlook and Exchange through many years of use. For a web-side gmail user, Picasa is the only choice.

Uploading to Print Services

For uploading to print services, Picasa is very simple. I select the photos I want to upload, and use one of the myriad pre-configured services, like CVS, Walgreens, Winkflash, Snapfish, Ritz, Kodak, Shutterfly, or one of about a half dozen others. This is distinctly different from PSE7, which offers only Shutterfly, and PSP which offers only CVS.

Captioning

Captioning photos in all three applications results in text being stored in the “Description” component of the IPTC block. In Picasa and PSE7 captioning is trivial—just click the “caption” line below the picture and type. Captions in Picasa and PSE7 appear below the picture in the file sorter mode. In PSP captioning requires clicking the image, and then scrolling down in the context pane on the right. You cannot tell which files have been captioned except by clicking each one (or possibly with a search).

In short, PSE7 and Picasa offer similar interfaces to captioning. PSP supports both tagging and captioning, but with substantially less convenience.

Tagging

Tagging in all three is accessed with a click. In Picasa tagging is accessed with a click on the little tag icon, which opens a dialog where you type the tags in. Auto-completion offers suggestions as you type, based on previously entered tags, which makes this painless. PSE7 tagging is richer, but I think harder to use. Tags are created and associated with a group, for example “people, friends” or “people, family”. This is tedious, and the categorization of the tags is not stored in the file. PSP offers simple text entry of tags, without auto-completion, categories, or even commonly-used tag lists. Tagging many files in PSP would be agony, but the interface is present adding or updating a few tags.

Historically I haven’t used tagging, but the ability to at least identify the subjects in the photo is compelling.

Raw Import

Import of camera raw files, in my case Nikon NEF from a D40, is supported in all three packages. There is no on-import control in Picasa, but it reads and imports the files without trouble.

Basic edits are well supported in Picasa, including satisfactory white balance, contrast enhancement, straightening, and cropping. Naturally PSE7 and PSP are extremely capable editing tools—far more so than Picasa. In a shootout of the file sorting and sharing capabilities Picasa is, without question, leagues ahead of PSE7 and PSP. Why consider a non-free package like PSE7 or PSP at all, if Picasa is so capable?

Remember that my journey started with color problems in a print. The final, and perhaps most important requirement, is that I be able to soft-proof pictures before I have them printed. Soft proofing is the process of approximating the appearance of the printed product on the computer screen.

Raw handling

The above picture is a composite of JPEGs produced by all three programs and the camera, all using program defaults on import. None of them are dreadful, but they are all very different. I chose this shot for demonstration, despite its awful composition, because it has a huge dynamic range. The black of the dog (Angus) next to the white of the fence in the sun has proven to be a very, very difficult shot to get well. The white of the fence is “blown out” or totally saturated.

If I spend some time and try to tune each import to get effects I want—such as details of Angus and relatively vibrant colors—I get the following.

The differences are still noticeable, but not huge. I like the PSE7 version slightly more (and it was easier to get), but the intensity of the colors is a little too high. The saturation should probably be somewhere between the PSP and PSE7 versions. Probably the take-away point is that you can get virtually anything you want the PSP, but there will be a few more steps than in PSE7 and a little experience required.

Picasa

Picasa imports my raw files without trouble. There is no active control over the import process. I assume that Picasa applies corrections for color and white balance, and any sharpening automatically. I also assume that the working bit depth for Picasa is 8 bit per channel, since modifications to a raw file are saved as JPEG images. While this makes Picasa capable of using raw images, it offers essentially no advantages over shooting JPEG.

In general the images Picasa imports are washed and look distinctly desaturated compared to the JPEGs produced by my camera.

Photoshop Elements 7

PSE7 can import my camera’s raw files. Indeed, I really like the PSE7 raw import tool. The tool, like most, provides adjustments for sharpness, brightness, white balance, and saturation. In addition, it includes an adjustment for the enigmatically named “vibrance”. Vibrance is a really wonderful control; it can give images from my Nikon D40 the kind of rich colors you get from a Nikon D300, without the improbable skin tones that come from simply cranking up the saturation.

However, PSE7 has almost no capability with 16 bit per channel images. I can understand why rotations, touch-ups, and so on are not defined for 16 bit per channel images, but I can see no excuse for leaving out color and light manipulation tools. Levels, curves, hue, saturation, and value adjustments must be defined for 16 bit per channel operations, or I get very little editing capability.

Paint Shop Pro

PSP imports raw images without trouble, though there is no special raw import tool like PSE7 provides. However, almost all operations are defined for 16 bit per channel images, including crop, rotate, sharpening and so on. All the effects available in the PSE7 raw import, except Vibrance, are available in PSP, except that they are not located in a single palette convenient palette. On the other hand, PSP can perform the levels, curves, and color correction operations on the full 16 bit per channel image, making it particularly useful for manipulating raw files.

Color Management

To see why color management can be so important, please see my article Introducing….

The picture shows screen captures I took using PSP with color management off, and with color management on, in “proof mode” below. The bottom picture represents quite accurately all the problems I observed in the prints I received.

Digital images represent colors with numbers, which must undergo transformation into control signals for devices like monitors and printers. Image files most commonly represent colors the sRGB or aRGB (Adobe) color spaces. A printer, or online developer might have a totally different color space defined. The printer or developer uses their devices profile, along with some kind of optimization protocol (called an “intent”) to transform your image into control signals for the device. For excellent detail on color management I recommend Color Management by Bruce Fraser, Chris Murphy, and Fred Bunting, a book I found to be deeply enlightening.

Practical color management starts in the operating system. Mac OS has provided OS-integrated color management since at least version 10.4 (Tiger), and possibly before. I don’t know if Mac OS natively supports on-screen proofing, or if that is application specific, as it is on Windows. Microsoft provides color management in Vista and XP, though at least the Vista version can be flaky, especially before SP1. The operating system level generally provides application of monitor, printer, and sometimes scanner calibration ICC profiles. The profiles are often generic, and therefore of dubious accuracy, but if you have calibration tools to get accurate monitor profiles, you have a chance of at least reasonably approximating the output. However, your application must support proofing mode, or at least this is true on Windows.

Color management is not a panacea—not all devices can represent all colors. Color management helps create pictures that look relatively good, or which have tolerable errors, but it does not mean WYSIWYG.

Picasa

Picasa offers no color management tools. You can still gain more accurate rendering by using a good monitor profile, but it won’t reveal issues in your print process.

Photoshop Elements

PSE7 offers no color management, either. Note though, that Adobe in general offers the best color management tools. In Adobe Lightroom and CSx you get tools like “show out-of-gamut pixels” which highlights areas in your image which will be altered during printing. I understand proofing modes are also supported.

Paint Shop Pro

Surprisingly, perhaps, PSP offers color management for proofing. In addition to “basic color management” which merely accounts for your display, there are proof modes that combine your monitor’s calibration with a printer profile to provide a reasonable representation of what you’ll see on paper.

PSP is not perfect in this respect. As far as I can see there is no way to transform your image to carry the information for the printer—in other words PSP helps you see problems, but offers little that is specially designed to help solve them. There is no “out-of-gamut” tool to provide a quick snapshot of problem areas.

GIMP

As of version 2.4, GIMP includes color management, with proofing modes and optionally out-of-gamut display. I tried this and it did not produce the same effects I got with PSP—that is, the picture looked fine in proof mode, and the only out-of-gamut areas were the subject’s pupils. In short, it did not work correctly. If it was my error then this may be the only affordable option to provide color management with near-Lightroom capability. Either way, prepare to invest significant time in mastering color management with GIMP.

Image Combining

Enhancing dynamic range by combining bracketed images is not something I expect to use substantially. However, there are cases where such a feature would be useful. Image combining can require alignment first, so some utility for image registration is probably required too. Picasa, unsurprisingly, does not offer an image combining capability. PSP offers one, including an alignment module. PSE7 does not appear to provide image combining, though I would not be surprised if Lightroom does.

Conclusion

My experience is that for sharing, basic editing, ordering prints, uploading, captioning, and tagging the free Picasa is unquestionably the best. For sophisticated editing Paint Shop Pro is a huge winner, with support for on-screen proofing, 16 bit per channel editing, bracketing combining, vector layers, and all of Photoshop Element’s editing capabilities except vibrance.

Maintaining monitor calibration is important, as is finding reasonable profiles for your printer or lab. However, the most important parts of color management are probably in getting the shot and in choosing the lab. If I weren’t so cheap I’d probably try Lightroom, which I believe has superior color management and presumably has more 16 bit per channel capability. However, I doubt its sharing utilities have much over Picasa.

Introducing…

Digital photography is a joy. Shortly before Christmas I ordered prints from Winkflash, and was appalled at their appearance. It was clear that I had a Color Management issue. I thought color management was analogous to the descriptions of wine. “Apricot with a hint of sunshine”—monitors can’t really be that bad, not if millions are sold every year.

I have been reborn.

An Experiment

But first the history. I got a bad print. Should I have been shooting raw to capture the full dynamic range? Did I goof with some easy white balance or exposure fix in Picasa? Did Winkflash misprint the picture?

Did I shoot the picture wrong?

Well, there is plenty to criticize, especially the bottom of the framing and the shallow depth of field. However, the exposure is decent, and the color is at least plausible.

Should I have been shooting raw?

That picture can never be reshot. Since the picture looks nice on the screen it is clear that truncated dynamic range was not the problem in this print. I had no experience working with raw (NEF, in the case of my Nikon); this experience has encouraged me to learn the value. Soon I will post my lessons of raw, and comments on the tools.

Did I goof with postprocessing?

No. The following picture shows the original and the printed version. I don’t remember the exact fixes I applied, except the obvious cropping. Any contrast stretching or color tuning are nearly invisible.

Did Winkflash misprint the picture?

In summary, yes. But so did Costco and Snapfish. The following section discusses the differences between the developers I compared.

Digital Photo Developers

In the above picture (O) is the original, (S) is Snapfish, (C) is Costco, and (M) is Mpix. I dislike the green and blue posterization and banding around her head from the Snapfish and Costco prints. It looks like she was cut out with scissors and glued on. The Mpix print is a little too desaturated—though I find the effect almost unnoticeable. The Mpix image has no obvious flaws, like the dithering or posterization. The differences between the original and the Mpix photo may appear because my scanner is not calibrated.

The Costco and Snapfish prints are both awful, but notice how different they are too. The Snapfish picture is much bluer, and has coarser dithering. Her skin looks too red in the Costco prints, and too blotchy in the Snapfish prints.

I am confident the relative difference between the three prints can be compared; the comparison to the original is possibly questionable. I scanned the three prints simultaneously so any scanner auto-adjustment would be consistent.