Home ›› Manipulation Tutorials ›› Simulating Depth of Field using Photoshop Lens Blur Filter
Simulating Depth of Field using Photoshop Lens Blur Filter

Last update:  12-31-1969

Submitted by bart_hickman

In this tutorial you will learn how to create the illusion of shallow depth of field using the Photoshop lens blur filter. You will also learn about the unique behavior of this filter. It is specific to Adobe Photoshop, however there are plugins available (they might even be free) that allow you to achieve similar results to the lens blur filter.

This tutorial is Copyright © bart_hickman, 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

Recommended

Rating
 

7

 

Expertise     7.9
Utility     3.6
Clarity     9.3
Relevance   8.7

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:
http://retouchpro.com/tutorials/?m=show&id=244

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: