Søk i denne bloggen og Lenker

mandag 27. september 2010

Photo Time: Simulated Depth of Field, blurred in GIMP

Simulating Shortened Depth of Field : Making a mask and applying it to layers to blur the background.

In the old days, most quality cameras could produce nice portraits with the background blurred. These days the smaller digital t cameras create a veryt deep depth of field because of the short distance to the sensor chip from the lens, so the background is often very sharp. On dSLRs too, some lenses don't «stop up» enough to give an open enough aperture to «throw the background» either.

The four-thirds system presents challenges in this area because of the relative stop down the short diaganols of the crop make. The kit zoom lenses are over f3 , but the 40-150 does throw the background at f5.6 it must be said. But many of my shots lack that really blurred background of my f1.7-1.9 primes from Pentax, Fujica and OM days. So my olympus E450 DSLR sometimes dissapoints in giving good heads so to speak!

However help is at hand because t you can make up for this in PS or GIMP etc, by drawing out a mask and using it with layers to paste a blurred background onto your original sharp foreground. In the image above you can get the idea!

I had a go at the GIMP GURU's excellent tutorial, but found for GIMP v2.6 that there were a couple of functions that either differed, or were desirable to use. Here are my own personal notes & tips which I hope are of use.

WHAT YOU ARE GOING TO DO: Work-in-porgress Images are at the bottom of the blog: you are going to make a couple of copies of the original, and then on one make a "mask" which will be the area the original, sharp background will shine through, so to speak. You will blurr the edges of the white mask so it merges to the soon to be fuzzy background, and then invert the colour to black. This mask is then laid ontop of the other copy which is first blurred in the software options. Finally you merge the mask to the blurred layer using " apply mask" and then stack this ontop of the original so the person or object appears sharp on a blurred background.


Small errors in the Layers Dialogue box can cost all: you have to take care to do things in the right order, with the correct settings for the "apply mask" and remember to stack them in the right order so the mask is on top.
: worth saving WIP copies as you go as xcf files.

"toggeling" between selected area after cutting and background on the mask build, then both in order to go through "cutting" the mast needs to be done fully awake!

Small mistakes in selecting what layer to see and work on make for a PITAss. take care that you work on the one you have the eye logo on and is highlighted.

It can also be difficult in cutting the mask and then blurring it's edges to get a natural fade into the background, with no halo and no sharp, unnatural edge or vignetted outline areas. Also, getting the right amount of blurring on the background


> Copy Original > Lasso Select Sharp Object e.g. person!

> Blacken bacground with paint can fill

> Work up mask in white with an underlying orig' image as guide in BW >

> Blur the edges very slightly to 4 or 5 on gausian, invert to black on white [SAVE A COPY!!! ]

> Open a copy of the original image and blur it to more than '20' on gausian

> [Add Layer Mask] to the blurred image ; NB as ['white opaque']> paste on the mask to this layer in layer's dialogue box

> Open the original as a layer in the window> move it down the stack order in the dialogue box

> merge down the stack to end with. [SAVE as jpeg]

In Detail: On GIMP v2.6

  1. Open image File, then CTRL D to make a duplicate GIMP window as a jhandy back up / reference

  2. Make a new layer as follows: [Pull Down]Layer>new from visible> duplicate this layer with CTRL D while in the layers dialogue box > rename the duplicate "Mask"

  3. Use the lasso to clip out the foreground or objects to be sharp. Go to a black and white view or a colour channel ( [Decompose], see GIMP GURU) if you need a clearer outline to work on ie more contrast between subject and background making it easier to lasso correctly

  4. Once the area is drawn around, double click/click on the lasso in tool bar. The area should now be selected inside a hatched line. Press [CTRL-I] to select background.

  5. Select FILL tool ( paint can) on black and fill the background

  6. Save a copy once you are here as an xcf file

  7. Now we want to try to force the outline of the subject to white. Right-click in the image and choose (Image/Colors/Threshold). Drag the middle pointer on the 0-255 scale left to extend white over the white areas

  8. If you have the image (copy from start) open as a layer, then make it grayscale: otherwise make a new layer and paste ALL of the original image onto it, anchoring the floating layer with the little anchor icon in the Layers dialogue window. Choose this new layer and reduce opacity to about 50 -60% such that you can see a ghostly effect : now you can check the mask fits and captures the area you want sharp. Once done, delete the mask guide layer by right clicking and selecting delete layer.

  9. Now apply a gausian blur to the mask layerAT ONLY 4 to 6 pixels: this blurs the edges of the mask such that it will run into the to-be-blurred background and avoids obvious lines. Once computed, choose COLOUR>INVERT to now make the image Black on White as the actual mask. Save this and save an xcf or jpeg copy.

  10. In the Layers dialog, select the original image in the drop down box if you have it or paste and anchor from the other original open. Then click the Duplicate Layer buttonDouble-click on the name of the top layer. In the Edit Layer Attributes dialog, rename the new layer “Blurred”.

  11. I (Filters/Blur/Gaussian Blur )). 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.Try 25 for a partial blur and over 40 for quite unsharp.

  12. SAVE A COPY of the WIP at this stage such that you can rework the blur if you feel it is not blurred enough or vice versa

  13. Go back to the Layers dialog and right-click on the “Blurred” layer; select “Add Layer Mask”.NB: At this point the next radio button selection is vital ! In the Add Mask Options dialog make sure White (Full Opacity) is selected. Then go to the black mask and select all and paste onto the blurred layer ONTO IT IN THE DIALOGUE BOX. Anchor it and deselect the eye on the mask itself

  14. You should see that there is a mask marked out in grey checker pattern over the area you want sharp and a nicely blurred background. Work back with CTRL Z if it is not to your burry liking!

  15. Open the original as a new layer. Move the orignal down on the list in the dialogue box so it is under the mask-blurred, and therefore will appear as the layer beneath on the final image. This shouuld now fill the masked area but be written over outside by the nice blurr you have created ! Jobs a gud'n.

  16. (delete the «mask»). Select the top layer, Blurred with mask, and then Choose Layers: [Merge Down ] save the image as a copy jpeg, keeping the main file as an xcf.

TIPS! When practising, reduce the image size and resolution to a web snap shot: this will make all the rendering and saving of your trial and errors a lot faster while you learn, and then you have a web ready series of shots!

TIPS! Be careful with the lower edge in portrait shots. When "cutting" ie outling the area to be the mask, check there is no foreground object to be blurred: short depth of field means it is just a slice into the distance which is in focus.

TIPS! It can be wise to give a margin to the figure for the edge blur: but if say it is a close up of a head with some diminishing depth of field on the person being good, then you can cut to the edge. This will vary with images : for instance, I find those with shadow from flash on one side need more there so that the shadow is softened. Trial and error will show you what works best, but it is difficult to extend a mask once «cut out».

TIPS! In GIMP 2.6 at least, when you have outlined the mask, and chosen to invert to background [CTRL I ] if the paintcan fill does not fill with black totally, then you can select a huge brush size and just go over it all in black: the foreground selected object will not be painted on as if it was "waxed". To fill in the mask itself, reverse with CTRL - I and then use white of course to remove any small specs or detail.

TIPS ! With similar images and a good contrast / edge to the background you do not really have to bother with an underlying black and white "ghost" to guide your fine working of the edges of the mask.

TIPS! Adjust the original for light before hand, but if it needs sharpening in the foreground, eg a face, then leave to the end ie sharpen the finished product and therefore make the background even more blurred in outset ( +40 in gaussian): In both cases - otherwise you will not get a good gradation between the masked background and the foreground / subject to be sharp or there will be an exposure discrepancy.

TIPS! Some edges are nice to leave really sharp with no gradation to the background on the mask. eg my wee one holding a feather in her mouth: the head likes a blurr on the mask of 5 px, but the feather looks wrong: Get round this by reworking the mask area after blurring the mask with the pain brush to give a sharp edge. It may be worth underlaying a "ghost" of the original again at this stage while the mask is white on black.

Footnote: Following on from that last tip:: According to GIMP GURU though " 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." as follows:

"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."



Too sharp

: too much detail in background to make the people stand out. The father is a little lost because the eye/brain places him more with the sharp sofa in the background

Mask WIP with blurred background. As you can see, the mask is not terribly detailed on the edges, but in this case it is quite sharp into the bodies with only a 3 or 4 pxl blur on the mask edge.

NB I have also been careful to exlcude foreground objects from the people so the foreground is also blurred, and been careful with the table edge and books: a lower edge should be checked for this in head-shoulders shots.


The eye now picks out the girls much quicker as being that to spend time on looking at, and the father is then pulled out more from the background detal.

The more you look at this shot, the more your eye-brain brings out the people from the background it now considers uninteresting!

I have put on an info dot to track any missuse of this photo. Pleas PM me before you copy this image for use.

Final with Crop

I like to crop! Here I could have used GIMP to "clone" out the light cabel/switch into to the beige wall in order to have a really clean image.

Note also: the fine detail on the LHS girls hair is not actually cut to a very fine mask detail: the eye/brain make the detail stand out more from the background now the rest is blurred but if when this is enlarged, the rough work shows in the hair and on a slight halo round the man's head. For enlargements, you have to trade off manual work in this area with what the eye won't actually pick up anyway. Here the faults are obvious at 15 cm so must be done.

Note also: I think I lightened the foreground layer but not the background in the image above, but got away with it because 1) the mask was only a 4 px blurr on the edges 2) flash was used in the original and it made the foreground lighter anyway: so the contrast is just enhanced in fact. This creates the halo on the man's head though if you zoom in.

Original cropped for comparison

All images (c) 2010 author. All text not quoted from GIMP GURU is original (c)2010 author

Ingen kommentarer:

Legg inn en kommentar