How can I fix the edges of foreground objects pasted onto a new background?


How can I cut out a foreground object, e.g. a person, from one picture and superimpose it onto a new background without making the edges look bad?

The problem I've come across is that if I have for example a white background and a dark blue object, there are some pixels at the edge of the object that are various lighter blue shades. If it were a black background instead, those pixels should be darker shades of blue instead of lighter; how can I change them appropriately when I want to replace the background? It's not too hard to fix this when I just have two colours, but what about when the imaged is varied, like with a photo of a person outdoors? I've tried blurring the edges of the object into the background, which is not awful but the edges don't look crisp enough.

I use Photoshop CS5 if there's a specific PS way of doing this.

6/25/2012 4:19:00 PM

Accepted Answer

This is called defringing, and Photoshop has a Defringe tool right under Layer > Matting.

However, you might not even need that tool in most cases if you're using the Quick Select with Refine Edge in CS5, or the Extract filter in earlier versions.

1/4/2011 10:04:00 PM

Its important to select the area you wish to cut/cutout very accurately. No automated tools will clean cut for you without having a good selection to start with.

that said this is my method:

I will regularly zoom in few hundred percent and using magnetic lasso to trace around the object or person. with add-to or subtract-from selection you can get it pretty accurate. Use quick mask and a brush to fine tune details.

Once you have a good selection Photoshop has a huge number of tools for improving it even more; personally i really like the improved refine edge tool with 'decontaminate colours'. Its especially great for fiddly selections around thinks like hair or fabric. Its also worth contracting your selection by 1 or 2 pixels, and feather the edge a very little bit.