Controlling Depth of Field With Lens Blur in Photoshop

Dateline: March 16, 2006
Version: Photoshop CS

More Photoshop tips
Discuss this in the Photoshop forum


Controlling depth-of-field before taking a picture has been standard practice since the invention of photography. The Lens Blur filter, introduced in Photoshop CS, provides a realistic way to simulate depth-of-field after a picture is taken.

Click to enlarge
Download the sundial.zip archive, open sundial.jpg, duplicate the Background layer (Command/Ctrl-J) to preserve the original, and save your work as a PSD file. From the Filter menu, select Blur > Lens Blur. You can see in the preview the blur uniformly affects the entire image as it would with any other blur filter. However, depth-of-field is a variable blur effect, so click Cancel.
Add a new layer, select the Gradient tool, and choose the Black, White gradient option. Draw from the bottom of the image (creating black) to the top (white). Press Command/Ctrl-A to select the entire canvas, and copy it. Now hide the new gradient layer by clicking its visibility icon.
In the Channels palette, click the Create New Channel icon to make an alpha channel. Select it, and paste the gradient from Step 2 into the alpha channel. Rename the channel Grad Only so later you’ll know which one it is. Click the composite RGB channel (the topmost one) to hide the Grad Only channel and redisplay the original image. Deselect the selection.

Click to enlarge
In the Layers palette, select the duplicate background layer, and choose Lens Blur again. It looks exactly as it did in Step 1, but now you have a depth map to control the blur. Select Grad Only from the Source pull-down menu. Notice the blur decreases from the top to the bottom. A depth map works like a mask, except it controls the amount of blur. The whiter values receive more of the blur and blacker values get less. This is better, but the sundial is blurred even though it’s the nearest object, which is a dead giveaway that your depth-of-field isn’t genuine, so cancel Lens Blur.
You need to be able to keep the filter from blurring the sundial. Make a new layer, and paint with black over the sundial. Click the visibility icon for the gradient layer, and move your newly painted sundial shape layer above it. Select All, choose Edit > Copy Merged, and turn off the visibility of the top two layers. In the Channels palette, create a new channel, select it, and paste the merged sundial and gradation. Rename the new channel Combined and deselect the selection.

Click to enlarge
Select the duplicate Background layer, apply Lens Blur again, but this time use the Combined channel as the depth map. Now we’re getting somewhere! The path gets increasingly blurred as it recedes into the distance, while the sundial remains sharp. Adjust the Radius in the Iris pane until you reach the amount of blur you want; I used a Radius of 30. Now click OK, and Photoshop will apply the blur using your settings and the depth map. Toggle the blurred layer off and on to see the difference. The final effect is shown at left.

Tip: In the Lens Blur dialog, leave Preview set to Faster during adjustments, but always inspect the image using More Accurate before clicking OK.

Don't miss the next Photoshop tip on Graphics.com. Get the free Graphics.com newsletter in your mailbox each week. Click here to subscribe.

Doug Nelson is a freelance writer, technical editor and founder of RetouchPRO.com.