Working With Difficult Extractions Using Adobe Photoshop CS
This tutorial is going to show you a quick and easy way to remove difficult images from their backgrounds. There are many, many ways to extract an object this is only one method and will not work for every image.
I'm going to use this image of somone you may, or may not, recognise for an example:
And change the background to this:
First, using the lasso tool make a really loose selection around the image. Just a general idea of what area of the image should be retained, it doesn't need to be exact or even really close.
Then click the mask icon at the bottom of the layers palette to create a layer mask from this selection.
The image should appear similar to this:
Looking at the layers palette, there is an indicator that the mask has been applied.
Look at the channels palette. To make the channels palette visible, choose to Window > Channels from the menu and the palette should appear.
Click each channel individually and find the channel that has the highest possible contrast between the subject and the background. Some images will not show very much contrast between the subject and background. In those cases, this method of extraction may not be the optimum way to work.
For this image the Red channel appears to have a good amount of contrast as you can see here:
Drag the red channel to the new channel icon at the bottom of the channels palette. This will duplicate the red channel and create a new, separate channel.
After creating a new channel, change the channel options for it. To do this, choose "Channel Options" from the flyout menu located on the channels palette.
From this window, name the channel and change the settings by clicking the "Selected Areas" option. This means that what is white on the channel is part of a selection and what is black is not.
Then just click okay.
This is our channel still:
Since the channel is set to make white areas part of a selection and the goal is to select the figure, the first thing to do, at this point, is invert the channel - Swap the black and white so that the figure is white and the background is black. Do this by going to the menu and choosing Image > Adjustments > Invert. The "Selection" channel should look like the following image:
Bring up the Levels Dialog box to adjust the channel. Choose Image > Adjustments > Levels. Move the sliders inward in order to get the highest possible contrast in the image. Do not pay any attention to interior areas on the figure, focus on the edges around the figure. The goal is to get as much edge contrast as possible.
After the levels are as close as possible to achieving a good edge on the figure, click okay. This, however, leaves a lot of areas in the interior of the figure that are grey or black. This needs to be a solid white shape in order to get a good selection of the figure.
When working on a channel, painting with a white brush will add to the selection, painting with a black brush will subtract from the selection. At this point, grab a brush, set the foreground color to white and paint away the black areas on the figure.
Here you can see the image after the levels adjustment and after most of the interior areas of the figure have been painted. As you can see, there are a few areas that aren't solid (Circled in red for clarity.)
These areas were left because it was not possible to get good, overall contrast in them without altering other areas and creating more problems elsewhere in the image. And painting white in these areas was not possible because the real edge of the figure was not clearly visible.
So are these areas fixed?
Painting with a white brush in these bad areas to fill in the selection and make it solid will work. But how can you paint where you can't see the where the edge of the figure is?
Go back to the channels palette and turn on the visibility for the high contrast channel again. (the red channel)
When the red channel is made visible again the image turns red. Red is an indicator of a visible alpha channel. It is not because the "Red" channel was turned on specifically. Turning on visibility for any single channel will result in the image turning red to indicate where the alpha channel is in relation to the color channel.
The red areas indicate the black areas on my "Selection" channel. This means that everything red is not part of my selection. Note the areas around the shoulders, you can see where red is bleeding through onto the figure. These are the areas that need to be corrected.
With a brush, foreground color set to white, and the "Selection" channel highlighted in the channels palette, begin to paint away the red areas.
Go around the image and paint away any red on the figure. When finished the red areas should only cover parts of the image that are not wanted.
Turn visibility back on for all the color channels by clicking the RGB channel in the channels palette.
Apply the "Selection" channel to the image. And in turn remove all the background from the figure. To do this hold down the Command key (Mac) or the Control key (PC) and click on the "Selection" channel in the channels palette.
When this is done the "marching ants" on the image should appear completely surrounding the figure.
The layer mask needs to be adjusted to use this perfect selection as the mask area. In the layers palette choose the layer mask that was created earlier by clicking directly on the mask indicator (The black and white thumbnail next to the layer in the layers palette.)
Be certain the layer mask is selected and not the layer itself. This is easily identifiable by looking at the little icon next to the layer in the layers palette. Note the little grey square with a white circle in it. This indicates that the layer mask is highlighted and not the actual layer contents. If the layer contents are highlighted this icon would be an eyeball.
The "marching ants" are still active on the image indicating the selection is still active, and the layer mask is highlighted in the layers palette. Fill the active selection with black to remove all areas that are not wanted. On layer masks black means hide and white means show. To fill these areas of the mask choose Edit > Fill from the menu. (To quickly fill an area with the foreground color you can hold down the Command key (Mac) or the control key (PC) and hit the delete (backspace) key on the keyboard.)
Here is the image after filling the layer mask.
The figure is now extracted almost perfectly from the background. There are a couple edges that are a little harsh. Places around the figure that don't blend well and look really "hard edged." To soften the edges up a little bit, slightly blur the layer mask. First, unlink the layer from the mask. If the layer content and layer mask are linked both the image and the mask will blur at the same time. To unlink the layer and the layer mask click the little chain icon between them in the layers palette.
With the layer mask highlighted, (remember to look for the little grey square with a white circle in it next to the layer in the layers palette) choose Filter > Blur > Gaussian Blur from the menu.
For this image use just a slight amount of blur. Only the edges of the mask need softening, do not blur it considerably.
Click okay and the image should be left with only a perfectly extracted figure showing.
Then place any background behind the figure and she'll fit well. Add a little shadow for her and it will blend in wonderfully.
Congratulations! -- You're finished.Have a question?