Welcome to my third installment in this short series on how to create deep focus images using Aperture. Today we will finally get to all the gory details of dissecting differently focused photos to create a single image where every object in the frame is sharp as a proverbial tack.
Recall from Part 2 that this experiment resulted in 9 photos, each focused on a different part of the scene. From one photo to the next, at least some area of the image is perfectly sharp, while the rest of the photo may be terribly out of focus. Doesn’t it make sense that we could take just the in-focus parts, leaving out the out of focus parts, and construct a single image where everything is sharp and clear?
That’s just what we are going to do.
The Big Picture
Before we get started it’s a good idea to look at the Big Picture before diving into the details. We are basically going to constrct a jigsaw puzzle, where the “pieces” are oddly shaped portions of the nine photos we have shot. Our pieces won’t necessarily have the precision of a jigsaw, where edges align at tight, exacting borders, but they will cover every inch of the canvas and seamlessly fit together to “paint” the entire scene. Our eventual goal will be to create puzzle pieces like the one you see on the right, as transparent TIFF files that can be composited together using a third party application.
Analyzing the image and getting organized
Nine photos means nine copies of every object in the scene. For the photo we’ve been working on, Engine 316 takes a detour on the glorious path to the Hereafter, that means we have nine versions of each and every object in the scene—nine giant devil heads, nine bikini girls emerging from the earth, nine skulls atop the log cabin—but we really need only one. The sharpest one.
In preparing to slice and dice this photo into various puzzle pieces I first took a good hard look at the objects surrounding a given point of focus to determine which areas were in focus for that photo, and whether or not that object/area was in the sharpest focus across all nine images. For example, in the “puzzle piece” we examined previously, the AF point had been on the dress of the dancing girl. In examining this particular photograph, the dancing girl (of course) was in very sharp focus. And, as expected, many of the surrounding objects—those within the calculated range of acceptable focus (an inch or so)—were also at their sharpest.
A second very important consideration into building a focus stack is to understand how the objects in your scene stand in “z-order (oooo! ahhh!) relationship” to one another. That’s basically a fancy way of saying that some objects stand in front of others (e.g. the dancing girl on the right stands in front of the menacing devil). Understanding the three dimensional relationship between objects will help you plan how all these puzzle pieces will eventually be layered together.
Think of the objects in your scene as laying on a series of vertical planes or “focus layers.” The background is the farthest layer and stands farthest from your vantage point. In our example, the record album cover (Movin’ On To Victory by Tammy Faye Bakker) is farthest from the camera and—since album covers are nicely flat—is a layer all by itself. The log cabin is slightly closer to the camera, so it (and the figures atop and within) can be thought of as comprising the next closest layer. So too the large devil head which is affixed to the album cover using mounting putty. It’s a tiny bit closer to the viewer than the log cabin, and stands alongside a band of three merry devils, each roughly the same distance from the camera. So the devil head and the three musical devils make up the next closest layer. And so it goes as we inch closer and closer to our vantage point, identifying objects and areas of similar distance from where we stand as the viewer.
Why it is important to maintain background-to-foreground consistency will become more clear in a bit when it comes time to reassemble the image from all our puzzle pieces. For now, just plant the concept in your mind and hang tight!
In any case, after careful analysis of the scene and the photographs I had shot, I broke down the image into the areas you see circled below, as a means of organizing the work to come.
I then created a folder for each area to be used as a workspace for generating the photo puzzle pieces, giving each a name like “Log Cabin” or “Devil Head” to help in identifying which objects I wanted that focus layer to include. The numbers that precede each folder name came later, after I had determined the back-to-front order of each layer. In any case, I now had a place to get to work!
Creating transparent focus layers using Aperture
As we saw earlier, our goal is to create transparent puzzle pieces. Strike that. We don’t actually want traditional puzzle pieces with hard edges that fit together like… well, a puzzle. What we want are pieces with soft, feathered, semi-transparent edges, so that the joining of two edges forms a nice, seamless, undetectable blend from one piece to the next. Seems like a job for Aperture’s adjustment brushes, which do an exceptionally nice job of creating soft, feathered edges.
Trouble is… Aperture lacks an “erase with transparency” brush, or any capability for exporting (or importing) images with transparency. That’s okay. With a little help, Aperture brushes can produce exactly what what we are after. The key will be to produce a mask that isolates only the in-focus portions of an image, then introduce that mask as the alpha channel of a TIFF or PNG file.
The steps for creating transparent layers using Aperture actually involve three different applications: Aperture, the Finder, and a third party graphics application that supports the creation of images with alpha channels. We’ll be going into each step in much greater depth than you see here, but a quick summary of process will help you see where we are headed:
- Select the photo you wish to use as the source for your transparent image.
- Export this image as an 8 bit TIFF to a folder on your Mac. We’ll call this your workspace.
- Open an adjustment brick that you do not intend on enabling in adjustments made to this image. I use Black & White for this purpose.
- Brush away the adjustment from the portions of the photo that are NOT to be included in your layer (i.e. brush away the transparent parts of the image).
- Disable (but do not remove) the adjustment.
- Quit Aperture.
- Locate the adjustment brush that was just created using my technique for copying Aperture adjustment masks.
- Copy the mask file to the workspace folder where you’d previously exported the unaltered image.
- Details will vary from application to application, but the basic strategy looks like this:
- Open the TIFF image exported from Aperture.
- Add an alpha channel to this image.
- Open the mask file we’d copied into our workspace folder.
- Copy the mask image.
- Paste the mask into the alpha channel of the TIFF image.
- Save the TIFF image.
- Voila! We have a transparent TIFF that shows only the portions of the photo we wish to include in our focus layer.
That’s pretty much all there is to creating a single focus layer. Later, we’ll combine all of our layers to create a single composite image with everything in focus, but first we’ll walk through the steps above to create a “focus mask,” finding the mask we’ve just created, and using that mask along with the original photo to create a transparent layer.
Creating a focus mask in Aperture
We’ll use Aperture to create the alpha channel mask for the transparency layers that will be applied to each of the photos in our focus stack. Generating a mask is really easy, as Aperture creates masks when adjustments are brushed into or away from an image. Which adjustment doesn’t really matter, as we only care about the mask Aperture generates, and we will not be enabling the adjustment after our brushing is complete.
I chose to use the Black & White adjustment brush to define my focus masks, as I don’t generally apply this adjustment to any of my photos, and the effect of the Black & White adjustment contrasts nicely with the areas you wish to mask.
Let’s go to work!
We’re going to create masked layers from each of our separately focused photographs. The first one is easy—the background layer, which doesn’t actually require a mask since it will lay behind all of the other layers, and—except for the image of the album cover—will be overlaid by all our other layers. All we have to do is:
- Select the photo shot with the focus on the album cover and export it as an 8-bit TIFF image. Easy!
We’ll edit the devil-focus photo by adding a Black & White adjustment.
- Enable the Black & White adjustment brick
- Select Brush Black & White Away and use the eraser to brush over the areas of this photo you want to be shown in the final image. In other words, you are brushing black and white out of the in-focus areas of the photo. This may be counter to what you would have expected, so a picture will surely help.
The image above was exported after brushing out the areas of the photo we don’t want to include in our focus mask. The in-focus area that will form the mask is shown in color, while the portions that remain in black and white are masked out.
Wow!! That was easy! How cool!
Don’t get too excited…. This is not your garden variety brushing.
Brushing to create focus masks
The strategy for using Aperture brushes to create a focus mask is not quite the same as what you would follow to brush in an image adjustment. Typically, when applying a brushed adjustment to an object, I meticulously fill the object right up to its edge, then feather the adjustment just inside the borders. But, remember, we’re not brushing in an adjustment. We’re defining an area of the photo that contains sharp focus, and—the way the eye perceives sharpness—the region we define must include the edges of objects contained within, plus a little bit of over-brushing that will be helpful in blending this layer with those that will lie below. So…
When erasing areas for your mask, brush beyond the edges of the objects you wish to include in the focus mask!
Zooming the above image to 100% illustrates how each of the four figures has been brushed to just beyond the edges (click to view at full size). Pay special attention to the area around the devil head, where you can see soft glimpses of color beyond the edges of the object.
Brushing beyond the edges of the target objects is further illustrated by turning on Color Overlay. Here, it is very easy to see where the black and white adjustment has been brushed away, leaving the primary objects contained inside our focus mask, plus juuuuust a little of the background.
Zooming even closer to 200% (the magnification level I usually choose for fine brushing) reveals the feathering that has been applied to the edges of the Black & White adjustment.
Feathering is greatest around the large devil head, and less pronounced around the smaller, more intricately shaped objects. The more gradual the feathering, the more gradual the transparency will be for this layer when we eventually blend the masked image with the imagery that rests below.
One last view at how our devil brush has been applied; this time taking a peek at the image with Brush Strokes enabled.
Ah ha! Looks like a mask, doesn’t it? In fact, that’s exactly what it is, and by examining the brush strokes we’re able to determine whether or not brushing is complete. Remember, we’re intending this mask to be the alpha channel that defines the transparent regions of an image layer. White regions translate to areas of transparency (i.e. out of focus areas we don’t want to see), black regions will be opaque (and in focus!), fuzzy areas will be a little of both and will blend with the layer below. Close examination of the brush strokes will quickly identify any areas that are not fully opaque or fully transparent.
Quick note about how Aperture really works!
Aperture treats the white parts of a brush mask as the area over which an adjustment will be applied, so the black portions indicate areas where an image adjustment has been erased. This is exactly opposite of what you find when looking at the alpha channel of a TIFF or PNG file that contains transparency.
Once brushing is complete, we can dig into Aperture, retrieve the mask file, and use this mask as the alpha channel for a layer that has only the in-focus parts of the photo in view.
Retrieving the mask file
Several months back I wrote an article on how to find and copy Aperture adjustment brush masks, and we’ll be relying on that article quite heavily to generate the masks we’ll need to create our focus stackable puzzle pieces. Where that post dealt with copying brushes from one adjustment to another within Aperture, here we merely want to find the brush mask file and copy that file so it can be used as the alpha channel for a transparent image file. You can read all the details here: Aperture brushes unmasked! Since writing that previous post I’ve since committed the task of locating mask files inside the Aperture Library to a Saved Search, which finds any modifications I’ve made today and sorts them by modification date. The most recent brush adjustment will always be at the top.
There it is!
Even though this mask was created with the Black & White adjustment tool, it’s really our focus mask. And once the mask has been located we can copy the file to the workspace we’re using to build this layer of our focus stack. The Finder window below shows the contents of this folder after the mask has been moved and renamed, alongside the full color 8-bit TIFF version of the photo exported from Aperture.
With both the photo and the focus mask safe and secure in our workspace folder we can combine these two files to create a single file transparent layer.
Creating the layer using GraphicConverter
I’m going to use GraphicConverter to set the focus mask as the alpha channel for our focus layer. I image other graphics packages such as Gimp, or Photoshop, could serve this purpose equally well. We just require an application that allows for the editing of image alpha channels.
The steps to add, modify, and save an alpha channel in Graphic Converter are not immediately obvious, but once you’ve gone through the process a few times it (like anything that requires computational learning) becomes second nature. We’ll go through each of the steps and illustrate the process.
- Open the TIFF file (Devil Head – Full Color.tiff) exported from Aperture.
With this exported copy of the original photo open, an alpha can be added.
- Choose Add Alpha/Mask Chanel from the Picture → Alpha Channel menu
- Choose Show Alpha Channel in new Window from the Picture → Alpha Channel menu
Well now, that wasn’t very interesting, was it? Black regions indicate areas of full opacity, and in this case—immediately after adding an alpha channel to an image—the entire image is opaque. We want to change the alpha channel to reflect the focus mask we created using Aperture.
- Open the focus mask (Devil Head Mask.tiff) previously created by Aperture and copied to our workspace folder.
This looks much more promising! We’ll copy this image and paste it into the alpha channel of the photo we exported from Aperture.
- Choose Select All from the Edit menu.
- Choose Copy from the Edit menu.
- Select the window that contains Devil Head – Full Color.tiff alpha channel.
- Choose Paste from the Edit menu.
You would think that with the black mask now replaced, we’d be done. Not so! As things stand, GraphicConverter treats the image we’ve pasted as an opaque black and white image that sits in the alpha channel. Black is black and white is white, and there is no transparency to be had! We need to turn the opaque black and white mask into an alpha mask with transparency.
- With the content of the window still fully selected (choose Select All from the Edit menu if that is not the case), choose Create Alpha/Mask Channel from Selection from the Picture → Alpha Channel menu.
Now, if you switch back to the window containing the original photo exported from Aperture, you’ll see our focus layer in all its transparent glory!
We can now Save As this image back to our workspace folder as an 8-bit TIFF file with transparency. We’ll call it Devil Head Layer.tiff to identify it as the layer of our focus stack that has only the four figures you see above in focus. If we open this file in Preview…
Demonic puzzle pieces!!
We’ll go through the process of creating transparent focus layers for each area of focus in the original photo, generating images like the one above for each. Once all our pieces are ready, we can start assembling the composite image.
Constructing a single in-focus image
We’ll use a third party application to combine all of our focus layers into a single image that has every object in sharp focus. Lots of graphic applications are capable of this task (GraphicConverter, Photoshop, Gimp, etc), so choose the application with which you are most comfortable. Just make sure it is capable of managing several layers of VERY LARGE images. In the case of the image we’ve been working with, I ended up with 10 layers, each of which was in excess of 34 to 40MB, so the final image weighed in at close to 400MB before it was flattened into a single layer.
If you’ve ever observed the way an artist constructs an oil painting, you’ll typically see him or her first painting in the background, then layering in foreground objects from back to front as the objects move closer and closer to the vantage point of the viewer. We’re going to do the exact same thing in building a single image from all of our layered puzzle pieces. Remember, as we were brushing the original images we made sure to include detail just beyond the edges of each object. By layering from back to front we insure that the sharply focused objects of a newly applied layer will always lie in front of objects that fall behind. We’ll illustrate these benefits in a moment.
The process for combining all the layers in a third party application are fairly straightforward:
- Create a new document window.
- Set the canvas size to match the dimensions of the photos exported from Aperture. In our case, we’ve been working with 3888 x 2592 pixel images.
- Drag a focus layer from the workspace folder and drop it onto the canvas.
- Set the position of the just dropped image to the origin, (0, 0).
- Do the above for each of the focus layers.
- Finally, export the combined image as a single 8-bit TIFF.
Normally, we’d lay down our background layer first, then apply all other layers atop this background. It’s good practice, however, to first skip the background layer and lay down all subsequent layers, one at a time against a white background to make sure that all the oddly shaped “puzzle pieces” fit together without gaps in between. Let’s take a closer look at this process by watching a quick animation of how the layers of our sample photo fit together.
Now, a stationary look at all the layers except the background.
Where you see white space the background layer will show through when we assemble the entire composite image from back to front. If white space is showing where you hadn’t planned on seeing the background, it’s time to go back to the brushing drawing board and adjust your focus masks. In preparing the layers for this photo, the initial composite construction revealed slight white gaps between many of the layers; primarily along the surface and faces of the record stacks. To correct those problems I went back into Aperture to alter the Black & White adjustment brushes so that my virtual puzzle pieces would overlap and blend correctly.
In the overlaid image above, the only white spaces we see are intended to peek through to either the background album cover, or the light tent (which will be cropped out of the final composite image).
Strange but true phenomenon!
Recall a statement I wrote much earlier in this series:
…and because the objects inside the light tent don’t move (ha! we’ll see about that…) capturing the images would be simple.
Well, in assembling this photo I discovered that the objects inside the light tent did move! In particular, the little tiny Dia De Los Muertos devil on the left had moved slightly. So too had the large devil head on the left. When overlaying their layers atop the background I discovered that the edges of those figures in the background where “bleeding through” the feathered edges of the foreground layer. Why? Because I light my photos with 1,500 watts flood lights, and—even though the complete photo session lasted no more than a minute—the heat generated by that much light does not agree particularly well with vinyl records and mounting putty!
To correct these very slight problems I offset the devil head layer by one pixel to perfectly align it with the background, and I extended the focus mask around the Dia De Los Muertos figure by just a bit to obscure the offset image that had been bleeding through from the background.
As you create your own deep focus images you’ll want to similarly examine the joining points of your layers and make slight adjustments to your focus masks to achieve a seamless blend between layers.
So… how does it look?
Actually… great!! Yes, it’s a lot of work, but the results are excellent. Remember the complex puzzle piece we saw at the beginning of this post? The one with all the fine brushing around the dancing girl? Here’s a detailed look at how that layer joins to the log cabin layer that lies beneath.
The layer blend around the dancing girl and the referee’s flag are perfect. Even at 200% magnification it’s very difficult to see where one layer ends and the next begins. Here’s a 200% zoom of the Dancing Girl layer, focusing only on the area around her outstretched left arm.
Now, the same area of the photo after it has been layered on top of the Log Cabin layer.
Even at 200% zoom it is very difficult to see, exactly, where one layer ends and the next begins, but objects in both layers are in sharp focus—which is exactly what we want!
Making image adjustments to focus stack images
There are (at least) two strategies that can be used in making adjustments to images created using my focus stack technique.
- Individual photos can be transformed into layers (i.e. our puzzle pieces) without any adjustments, combined, then imported back into Aperture as a single TIFF image. The TIFF image can then be adjusted to create the final image.
- Each photo can be separately adjusted, then transformed into a layer, with the final image composed outside Aperture.
I actually used a combination of these strategies in creating Engine 316 takes a detour on the glorious path to the Hereafter. Each of the nine original photos were given the same adjustments for Exposure, Levels, and a few other things that I knew would apply to the whole photo, independent of any single object or area. Photos were then individually adjusted where objects within that photo could benefit from specific brushed improvements (Noise Reduction, Colors, Vibrancy, Definition, Retouching, etc…). After the layers were combined, I imported the resulting TIFF file back into Aperture where the final image was cropped and a vignette was added.
The final result with everything in focus.
I hope you’ve enjoyed this short series on how to use Aperture brushes to create deep focused images, and I hope you’re inspired to see what you can do to extend the capabilities of the tools we’ve been given to improve our photos.
Please let me know if you have questions. I’ll do my best to clarify things were I can!