Sunday, January 06, 2008

Replacing A Sky




“Cheating?”
Yep. Get over it. Most of us can’t drop everything and get the perfect shot on the perfect day, or stay in New York until the sky is great over the Statue of Liberty.

Keeping a sky library


Of course if you’re going to replace bad sky with a good one, you need to have a good sky handy. It’s tempting to bag a sky when it’s a dramatic sunset, and you should, but you should also have a collection of nice noon skies as well.
When you see a nice sky, shoot it both horizontally and vertically. Also use various focal lengths so you will have a pattern that matches the scene you’re trying to fix.

Bringing the two together


Start by opening both images in Photoshop. Adjust the image with the bad sky (the “main” image) for color, contrast, and density, and then flatten the image. The point here is to create a starting point where both images are compatible.
Select the sky with the magic wand tool.
Make sure “Contiguous” is unchecked. Even in this relatively simple example, there are numerous areas where the statue creates isolated areas of sky. We want them all to be selected.
Click with the wand out in the sky area. If the wand does not select the entire sky, there are a couple of things you can do to fix it. One is to deselect (ctrl-D), increase the tolerance, and try again. Another is to hold the shift key down and click with the wand again in the unselected area. The shift key puts the selection in “add” mode. A little plus sign will appear next to the tool.

How it works


The magic wand tool selects based on brightness. It adds and subtracts the value in the tolerance box to the value of the pixel where you click and selects all other pixels within that range. It does this for each channel. For example, let’s say a pixel of my sky is R229, G227, B222 (a slightly warm bright gray) and my magic wand tolerance is 15. The tool will select all pixels with a value in the range R(244-214) G(242-212) B(237-207)

The key is the selection


The magic wand tool is just one way to select an area. They key is to get the sky selected, not how it’s selected.

Copy the sky


Switch to the sky image. Press ctrl-a to select everything, then ctrl-c to copy.
Next switch back to the main image and make sure your ants are still on the march. Paste the sky into the selection with Edit -> Paste Into (shift-ctrl-v).
You will get a new layer and a mask.
You can position the sky by using the move tool (V). You can also stretch, shrink, or otherwise change the sky by transforming it. Press ctrl-t and drag the handles around to transform the sky. Skies can take an amazing amount of manipulation and still look good.

Fixing the halo


You may or may not get a halo around the edge. In the image above, the original is on the right; the image with the replaced sky is on the left. There are a couple of things to notice here. First the halo on the left is caused by the selection not being perfect, and the mask isn’t 100% right up to the statue edge. That’s allowing a pixel or so of the original sky to bleed through. (This shot is with both images enlarged to 1600%.) The other thing to notice is that no edge is always perfectly crisp at this level of zoom. Natural edges transition over 3 or 4 pixels.
If you have a halo, you need to fix it. Essentially what you have to do is refine the mask Photoshop created for you using the same techniques you always use to deal with the mask. What we’ll do is make the mask slightly smaller, allowing less of the background image to show through.
Zoom way in, use a very small brush and paint white on the mask along the edge.

Avoiding the problem


You may be able to avoid the problem by expanding your initial selection. After you click with the magic wand, use the menu to select Select -> Modify -> Expand and add one pixel to the selection.
Note that this isn’t always best. You may have some cleanup to do around the edges in the other direction. In this case, the edge of the torch is too sharp, and I need to use black on the mask with moderate opacity to smooth it out.
The best sky to replace isn’t a white sky, it’s a blue sky. Notice that when the edge selection isn’t quite right the halo comes not where there replacement has a cloud, but where blue is getting substituted on top of the original white. That original white shows up as a halo in the replacement blue sky. Where there is a nice white puffy cloud in the replacement sky, the white halo is still there but you can’t see it because it’s white on white and it looks natural. That means the best replacement of a totally white flat cloud sky is one with some blue but also a lot of clouds. It also means positioning the replacement sky clouds under your fine detail means less cleanup than positioning the blue replacement there.

Understanding Photoshop tools


If you’ve ever wondered what a tool or option does in Photoshop you’ve probably discovered that the Photoshop help file is totally useless. What the help system should have told you is in the Photoshop 6 Shop Manual by Donnie O’Quinn (ISBN 0-7357-1130-5). Alas it hasn’t been updated for later versions of Photoshop. Still, most of the tools you use and most of the options are unchanged from this version. For example, if you want to know how each blending mode works, or exactly what each option for the magic wand does, this book will tell you. It’s available used on Amazon from $9.49 to $39.99. There are 13 reviews, 12 five star, and 1 one star. The one star guy wasn’t arguing about the content, but bitching about the binding. I’d take it if it was loose sheets. As one reviewer said, Breathtakingly useful... an indispensable resource. There is really nothing else like it.

Non-Destructive Dodging & Burning


Dodging and burning is a practice in the darkroom as old as photography itself. Photoshop has built in tools for dodging and burning, but I don’t recommend their use. The reason is that the dodging and burning tools are destructive – they permanently change the pixel values in the image. What we really want is a non-destructive way to dodge and burn, like an adjustment layer. That way we can easily undo, throw away, or correct what we’ve done.

Transforming an Image


The original below was no better than forgettable, but with some cropping and the other techniques we’ve covered – and some dodging and burning – the potential comes out.

Creating a Dodging & Burning Layer


Make sure the layers palette is visible. Hold the alt key down and click the new layer icon in the layers palette.
This brings up the new layer dialog. If you forget the Alt key, Photoshop will just create a new blank layer and not display the dialog. If this happens, drag the layer to the trash can in the bottom right corner of the layers palette and try again.
With the new layer dialog up, enter a nice descriptive name, change the blending mode to “Soft Light” and click the check box. Each of these is important.

Applying Dodging & Burning


Once you’ve got your layer in place, paint directly on it with either white (to dodge) or black (to burn). Start with low brush opacity and build up the effect you’re looking for. Remember to release the mouse button between clicks. If you need to reverse the effect of what you’ve done, switch the brush color to the opposite one and go back over the area.
In dodged areas, I frequently find I need to add a little contrast, so I do that with a curves layer and a mask.
In the final image, the dodging and burning focuses the eye in the intended area of the image.

Dodging & Burning or Levels Layers & Masks?


You could achieve the same results using multiple levels adjustment layers with masks, but you will probably find when you have to tweak the image a dodging and burning layer is easier.

Non-Destructive Cloning



My favoite Texaco sign (in Talmo, GA) makes great cloining practice.
Let’s start by fixing my head-tilt. Select the entire image with ctrl-a, then transform it with ctrl-t. Twist the corner until it’s straight.

Clone on a new layer


Cloning on a separate layer gives us the opportunity to undo and discard our cloning. It’s much easier to fix our mistakes or change our mind this way. For example, if I did a photo essay on visual pollution caused by power lines, I’d want to bring those back.
Start by clicking the new layer button on the layers palette. If the layers palette isn’t visible, press F7.
Next, select the clone stamp (S). Make sure “Current and Below” is selected in the toolbar “Sample” options.
As you clone, the cloned pixels appear on the new layer, they don’t change the original layer. As a result, you can start over by throwing away the cloning layer. You can use this approach multiple times. For example, I might have one layer to fix the edges created when I rotated the image to straighten it out, and another layer to get rid of the power lines. This makes it easier to isolate choices and mistakes.

Tips for cloning


Work on the full size image


You want lots of pixels to play with. Start on the full size image, before you do any resizing. Zoom way in. Remember the space bar turns any tool into the hand tool, so you can hold the spacebar down, drag the image around, and when you release the spacebar the tool goes back to the clone stamp.

Modify the brush hardness to your task


Work with a soft brush when you’re not up against a hard edge. Work with a hard edged brush when you’re cloning near a hard edge.
Here I’m working with a brush size of 5px and a hardness of 90%. Away from the sign edge, I’ll use a larger brush, about 12px, and a hardness of 0%.

Use shift-click to clone in a straight line


Click once at one end of a line, such as the power line. Then position your tool over the opposite end of the line, hold the shift key down, and click again. The clone tool clones the entire line.

Avoid ghosting your target back in


You generally want to sample from as close to the target as possible so the tones and texture are as close as possible. Frequently though, you can run into yourself when cloning close by. The stamp tool clones by sampling the underlying pixels and copying them to the destination. It keeps taking from the underlying pixels until you release the mouse. The cross-hair indicates where the tool copies from. Note that in this case, I’ve moved the cross-hair to where the power line is and the destination down below the original line. Because of this, it copied the power line down as well, even though the area where the cross-hair is shows blank sky. The sample is coming from the underlying pixels, and the power line is still there.
When you release the mouse and click again, it picks up the changed pixels so it will begin copying clear sky. You have to balance the tedium of clicking a lot with the problems sampling from further away.

Know your keyboard shortcuts


· s for the stamp tool
· z for the zoom tool
· Spacebar for the hand tool
· [] (left and right brackets) to increase or decrease the brush size.

Aligned vs. Non-aligned


The “Aligned” checkbox controls where the sample starts from when you release and re-click the mouse. When you drag the mouse the sample position always moves in parallel to the brush. If the aligned box is checked, when you click again the new sample starting point is in the same relative position as the first time. If the aligned box is not checked, the new sample starting point is the original absolute position.

Layer order matters


In the image below, I’ve introduced a levels layer between the background and the cloning layer and adjusted the contrast. This brightened up the sky. Because the cloned pixels are copied from the lower level which is in its darker state, dark lines show up. Put your cloning layer directly on top of the image layer, or wait until the cloning is done and add the adjustment layer on top of both. Don’t forget you can change the order of the layers just by dragging them. Dragging the levels on top the clone layer fixes this problem.\

Working an edge


When cloning along an edge, you must take care not to distort the edge. To do this, you must line up the center of the sample with the center of the target. To do this, make sure the sample is right on the edge. When the alt key is pressed, the cursor turns into a “precision” cursor. Put it right on the edge before clicking the mouse. Without releasing the alt key, move the cursor to the clone target, and then click. If you need to later find the center again, you can press the alt key without clicking. Just holding the alt key down only shows you the center cursor, it doesn’t change the sample.