Home ›› Manipulation Tutorials ›› Depth Map
Depth Map

Last update:  12-31-1969

Submitted by Doug Nelson

Use the Lens Blur filter in Photoshop CS with a depth map to realistically simulate depth-of-field

This tutorial is Copyright © Doug Nelson, who has sole responsiblity for its content.
Have a question for the author? Or simply want to discuss this topic further? Click "Discuss" up at the top. If you'd like to publish a tutorial of your own, simply click on "Publish" over on the menubar.


Overall Recommendation





Expertise     5.3
Utility     5.1
Clarity     4.5
Relevance   5.4

Controlling depth-of-field before taking a picture has been standard practice ever since photography was invented. With Photoshop CS and its new Lens Blur filter, we finally have a realistic way to simulate DOF after a picture is taken.



1          Open your image. Any blur filter is destructive, so make a duplicate layer to preserve the original and save your work as a PSD file. Activate the duplicate layer, and from the Filter menu, select Blur > Lens Blur. You can see in the preview that the blur uniformly affects the entire image, just as it would with any other blur filter. But depth-of-field is a variable blur effect, so click Cancel.






2          Make a new layer and use the Gradient tool to draw a gradient from black at the bottom of the layer to white at top. Press Cmd/Ctrl – A to select the entire canvas, and press Cmd/Ctrl – C to copy it to the clipboard. Then hide the new gradient layer by clicking on its visibility icon.





3          In the Channels palette, click on the Make New Channel icon, located at the bottom of the palette. This creates a new channel named Alpha 1. Press Cmd/Ctrl – V to paste the gradient from step 2 into the new alpha channel. Rename the channel Grad Only so you’ll know which one it is later. Click on the composite channel (the topmost channel, labeled RGB) to hide the Grad Only channel and redisplay the original image.



4          In the Layers palette, click on the Background Copy layer to make it active and select Lens Blur again. It looks exactly as it did in step 1, but now we have a depth map to control how it applies the blur. Click on the Depth Map option menu and select Grad Only. This is the alpha channel we made in step 3. Notice now that the blur decreases from the top to the bottom. A depth map works like any mask, only it controls the amount of blur. The whiter values receive more of the blur and blacker values get less. This is a big improvement, but the sundial is blurred even though it’s the nearest object, which is a dead giveaway that our DOF effect isn’t genuine. Cancel Lens Blur.





5          We need to keep the filter from blurring the sundial. Make a new layer and paint the sundial shape in as black. Click the visibility icon for the gradation layer and move our newly painted sundial shape layer on top of it. Select the entire canvas and use Edit > Copy Merged to copy the combined layers, then turn off their visibility. In the Channels palette make a new channel and paste in the merged sundial and gradation. Rename the new channel Combined.



6          With the Background Copy layer active, run Lens Blur again, this time using the Combined channel as the depth map. Now we’re getting somewhere! The path gets increasingly blurred as it recedes into the distance, yet the sundial remains sharp. Adjust the Radius 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 using the depth map. Toggle the blurred layer off and on to see the difference.





In the Lens Blur dialog, leave the Preview mode set to Faster while making adjustments, but always inspect the image using More Accurate before clicking OK.