Thursday, March 20, 2008

Replace background

Step 1 - Open a studio portrait with a solid color background

Below is an image I opened to demonstrate this tutorial. The image below is an example of one of the worst situations. For portraits, a good color background would be green or blue. But for this tutorial, I will use a studio portrait with red background and lots of skin, hair, and even a drop shadow to show you this tutorial in the worst situation. In most situations, removing background will be a lot easier but it is important to learn how to mask difficult images so that you're prepared to mask most images.

Image

Step 2 - Select a color range

Choose Select > Color Range. In the Color range tool, click on the background. Hold the shift key and continue clicking the background until you have the entire background in white. Click OK when done.


Image

Step 3 - Smooth the selection

The selection may look perfect, but if you zoom in you can see that it may not be especially if you're trying to mask hair. To fix this, choose Select > Modify > Smooth and smooth the selection by 1 pixel. This will remove all tiny dots without making the selection too round. Making it too round will cause problems with the hair later.


Step 4 - Create a layer mask

First, to create a layer mask, you will have to unlock the Background layer. To do this, double click on the layer and a window will appear with the layer settings. Just click OK with the default settings.



Now choose Layer > Layer Mask > Hide Selection. This will create a new layer mask with the selected area (the background) in black.

Step 6 - Manually paint the mask to correct errors

Hold the Alt key and click on the layer mask thumbnail. You should now see the black and white layer mask in the document window. You can see that the mask is not exactly perfect. For example, the red lips was masked out because Photoshop thought it was part of the background when we used the Color Picker tool. To fix this, just paint it out with white using the brush tool. But make sure that you're working on the layer mask and not the layer.


Step 7 - Place the background file

Choose File > Place, browse for the background image file and click OK. The image should be placed into Photoshop as a new layer with a transform box allowing you to resize the image. Resize the image so that it its into the document boundaries. When resizing, hold the shift key to main the image aspect ratio.



Move the layer to the bottom. We've just masked an image, but wait we're not done. Look at the image below. The hair still has a red outline and near the legs (not shown in the picture), it has a red glow. This was caused by the drop shadow in the original image. In the next steps, we'll work on fixing this issue and working on the hair.

Step 9 - Use the Levels tool to shrink the mask.

First, zoom into an affected area with the glow. Select the layer mask then open the Levels tool (Image > Adjustments > Levels). Move the middle slider towards the right until the edge glow disappears.


Step 10 - Sponge the hair

There will still be some slight outlines around fine details such as the hair. Use the Sponge tool on desaturate mode and paint carefuly on the edge. Because the hair is usually not completely grayscale (black hair has some browns in it), you want to be careful not to over apply the sponge tool. Work only on the edge and zoom in so that you can be more precise.

If you're working on hair that's not black, create a new Hue/Saturation adjustment layer, check mark colorize, and adjust the settings to match the hair color. Then, click on the Hue/Saturation layer mask, press Ctrl+I to invert, and paint the affected areas with white.


Step 11 - Match the two layers

The mask is perfect now, but we're not quite done. This final step is one that many people forget and it is the most important step to make it look real. That is to match the brightness, contrast, and saturation with the background image. Add the appropriate adjustment layers but don't edit the settings yet. For the image I used, the saturation is fine so I will just add a Brightness/Contrast adjustment layer to fix the brightness and contrast.

Once you have the adjustment layer, you need to create a clipping mask so that it only affects the layer below. To do this, press Alt+Ctrl+G and it will create a clipping mask that will only affect the shape of the layer below and not the background.



Once you've done that, adjust the settings so that it matches the background. For example, the background I used has higher contrast and brightness. I will increase the contrast and brightness to match the background so that they blend in.

Final Results

No comments: