|
All photographs and articles on this web site are
Copyright © Eric R. Jeschke
(contact info
Site designed for screen resolutions of 1024x768 or greater. You may wish to maximize your browser for best viewing. |
|
GIMP Resources for Photographers
Home | Tutorials | Ask the guru | Mailing list | Flickr Forum Support | Translations | Fan Mail | Download | FAQ Adjust gamma |
| Before | After |
|---|---|
|
|
In this tutorial I'll show you how to simulate a shallow depth of field using image editing techniques. It is painstaking enough that it is no substitute for having camera equipment that is capable of the job. Nevertheless, it can be useful in rescuing the occasional picture.
|
Load your image into the GIMP.
I thought this portrait would look better if the background wasn't quite so distracting. |
|
||||
|
The most difficult thing we will have to do is creating a mask
for the subject. We will try to find the "natural mask" that is
already in the image and so use this to make our work much less
tedious.
The best contrast between items can often be found in the green channel. It's a good place to start looking, in any case. So the first thing we will do is decompose to individual RGB channels. Right-click in the image and choose (Image/Mode/Decompose). In the Decompose dialog box, choose RGB and click OK. Examine each channel to find which has the best contrast for isolating the subject. In this case the green channel image was the best.
|
|
||||
|
Close the other two images that you aren't going to use. With a
little work this green channel image will become our mask.
First we'll minimize our work by drawing a selection outline
around the subject with the lasso tool
( |
|
||||
|
Now invert the selection (Ctrl+I), choose the fill tool
( Clear the selection (Shift+Ctrl+A). You should see something as shown on the right. |
|
||||
|
Now we want to try to force the outline of the subject to
white. Right-click in the image and choose
(Image/Colors/Threshold).
In the Threshold dialog click in the histogram and drag to the right, as if you were selecting the right half. You will see the image go to black and white, with everything to the left of the selection going to black, and everything in the selection going to white. Experiment with different selections until you have one that gives the best isolation of the subject in white. When you are satisfied, click OK. |
|
||||
|
We're going to manually touch up the mask to fix any last
imperfections. Here's where the work can get a bit tedious. If
you've found a good contrast between subject and background and
exploited the lasso, fill and threshold steps well you shouldn't
have too much drudge work at this step.
To help us out we're going to composite the mask and the image.
Open the Layers dialog (Ctrl+L) and click on the New Layer
button ( Now go to the original image window (you didn't close it did you?). Select All and Copy (Ctrl+A then Ctrl+C). Now go back to the mask image and paste into the new layer (Ctrl+V). It should paste as a grayscale image. Finally, in the Layers dialog, anchor the pasted image and reduce the opacity of the Mask Guide (upper) layer to around 70%, as shown. The image should look something like what is shown in the lower right. What this does is allow you to view the image and the mask at the same time, overlayed, while you work on the mask. |
|
||||
|
Before you leave the Layers dialog, select the Background layer
in the mask image (that's the layer we want to work on), as
shown at right. The Mask Guide is just to guide us.
Select a reasonable brush (usually small and fuzzy) from the
Brushes Dialog (Ctrl+B), select the Paint tool
( You'll probably need to use a few different brushes. Zoom and pan around the image. Switch back and forth between Black and White (x) and take lots of small steps so that you can make use of the excellent Undo capabilities of the GIMP. Periodically you can turn off visibility of the Mask Guide (by clicking on the "eye" next to that layer in the Layers dialog) to view your mask's progress. When you are all done, I suggest saving the mask (as an XCF file) so that all that painstaking work does not have to be replicated later if you decide to re-edit the image. |
|
||||
|
Do a small Gaussian Blur (Filters/Blur/Gaussian Blur (IIR)) of
about 5 pixels or so on the mask.
Then invert the mask (Image/Colors/Invert). |
|
||||
|
In the Layers dialog, select the original image in the drop down
box. Then click the Duplicate Layer button
( Double-click on the name of the top layer. In the Edit Layer Attributes dialog, rename the new layer "Blurred". |
|
||||
| In the original image window, right-click and select (Filters/Blur/Gaussian Blur (IIR)). Experiment to find a value that works well for your desired "depth of field". Generally you won't want to go too crazy with this or the look will be all wrong. Here I used a value of 40. |
|
||||
| Go back to the Layers dialog and right-click on the "Blurred" layer; select "Add Layer Mask". In the Add Mask Options dialog make sure White (Full Opacity) is selected. Your Layers dialog should now look as shown at right. |
|
||||
|
Go to the mask image window and Select All and Copy (Ctrl+A then
Ctrl+C). In the original image window, Paste (Ctrl+V). This
should paste the inverted mask into the layer mask.
In the Layers dialog, click on the anchor button to anchor the pasted image. Voila! Your subject should be clear and sharp, while the background appears soft and out-of-focus. |
|
If your subject and background are less defined than what is shown in this example (e.g. a landscape with a prominent foreground) you may be able to get away with simply using an appropriate black-white gradient as the layer mask.
Another possibility is to duplicate the layer, use the "lasso select" tool to select around your subject and then feather the selection heavily. Fill the selection with black then invert the selection and fill with white. Select all and copy to the mask.
Last modified: Sun Jan 9 21:02:09 HST 2005
|
|