2008-Aug-4 update regarding CS3: Adobe enhanced the lens blur filter in Photoshop CS3 (it now blurs opacity as well as color). So this tutorial only applies to CS2. If you are using Photoshop CS3, please visit the tutorial, "Simulating Depth of Field using Photoshop Lens Blur Filter--2nd Edition" instead.
This tutorial is a companion/sequal to my earlier tutorial using the gaussian blur filter:
The techniques of both tutorials can be combined to create advanced DOF effects.
Sometimes it's not possible to shoot with a shallow-enough depth of field to achieve the effect you're after. One possible reason is the subject itself has depth and we'd like it completely in focus (eg., flower), but we still want the background blurrier. Another reason is your camera simply can't do a shallow DOF.
We will start with this original image shot with a P&S camera at relatively short focal length and large depth of field (DOF):
...and make it so it looks like it was shot with a shallow DOF like this:
The first step is duplicate the background layer (ctrl-j). This new layer is labeled layer 2 in this tutorial. The starting layer palette will look like this:
The park bench is the subject we want in focus so we start by selecting the park bench on layer 2. I used a combination of magnetic lasso and polygonal lasso for this subject due to its simplicity. If the subject had been complex like a person with wispy hair or a tree I would have also employed the extract filter and/or image-based masking techniques. Iíll leave methods of selection to another tutorial as thatís a whole topic of itís own (in fact, it's a whole book).
Once you have it selected, hit the delete key to remove the bench from layer 2. You should now see this (I turned off the background layer so I can see what Iím doing.)
Next create a mask for this layer (click the create mask icon at the bottom of the layer palette), then select the mask icon in the layer palette (to make sure itís active), then draw a black to white gradient starting from the base of the trees in the distance and going vertically to the bottom of the photo. You'll see shortly weíre creating a depth map where black is far away and white is close and grey is in-between.
This figure shows how Iíve clicked-and-dragged the gradient path just before releasing the mouse button. The path starts at the top (most distant) of the grass and extends to the bottom.
...and now releasing the mouse button to cause the gradient to be drawn:
The gradient is now in the mask, but Iím not actually using the mask layer as a mask layeróIím just using it as a convenient place to store what will become the depth map for the lens blur filter. So I disable the mask so it doesnít operate on the layer--the layer palette should now look like this:
(Note: for simplicity, I'm using a standard linear gradient. However, to properly simulate DOF, you need to use what would be called a quadratic gradient. A quadratic gradient varies as distance squared. I'll modify the tutorial with that information when I get the chance.)
Notice that the mask thumbnail is selected. Before doing our next step (the lens blur filter), you need to select the layer thumbnail by clicking it. Now open up the lens blur filter.
Here's part of how it looks:
In the depth map selection, set the source to ďlayer maskĒ. This tells the lens blur filter to use the gradient we drew as the map it uses to change blurriness across the layer. Slide the blur focal distance slider until the grass under the bench is in focus. In this case, grey level ~182 represents perfect focus and all other shades are progressively more blurry the more different from 182 they are.
In the iris section adjust the radius to suit your taste.
When you're done adjusting, click okay.
At this point I want to take a small detour and point out a unique feature about the lens blur filteróit doesnít change the alpha channel of the layeróie., it doesnít blur the edges of the bench cutout. By comparison, the Gaussian blur filter does blur the edges. To see what Iím talking about, let's compare the lens blur and Gaussian blur filters.
Here's the Gaussian blur:
Here's the lens blur:
Notice that both filters blur the pixel colors, however, the lens blur cutout is still sharp even though the pixel colors were blurred (pixel opacity was unchanged.) The Gaussian cutout was blurred right along with the pixel colors (pixel opacity near the edge of the cutout was modified.) Itís good to keep this difference in behavior in mind when using these filters for DOF modification, because it affects the ordering of the layers depending on which filter you're using.
Okay, getting back to the tutorial. Now turn the background layer back on and youíre finished. The layer palette should look like this:
You have the bottom original image (background) and the top blurred image with the bench cut out (layer 2). The original bench shows through the cutout. Hereís our final result once again: