Sub topic 8
Blending cut-out edges
A cut-out can match the background in light, colour, and perspective and still look pasted in. The cause is often the edge. This chapter covers how to clean and soften the boundary between a foreground element and its new background.
This chapter assumes you can make selections, add layer masks, and use adjustment layers, as covered in the setup chapter. It builds on the non-destructive structure from that chapter, so every step here edits a mask or a clipped layer and never the original pixels.
Why edges give a composite away
A real photographed edge is never a perfect line. Three things happen at it:
- The lens and sensor soften it slightly, so the transition from subject to background spans one to several pixels.
- Light from the original background leaks around it. This is usually a thin fringe of the old background colour.
- Fine detail such as hair, fur, or leaves produces partial transparency, so the background shows through.
A cut-out made with a hard selection removes all three. The result is a crisp outline with a halo of the wrong colour. Your goal is to put back a believable transition, in the right colour, at the right softness for the scene.
Start with a good mask, not a good selection
Do the cut-out as a layer mask on a Smart Object, so you can keep refining it.
- Convert the foreground layer to a Smart Object.
- Make a selection with Select Subject, Quick Selection, or the Pen tool.
- Open Select and Mask (Select > Select and Mask).
- Set Output To to New Layer with Layer Mask or Layer Mask.
In the Select and Mask workspace, switch the View mode to On Black or On White, or better, to a colour close to your real background. Edge problems show up much more clearly against a similar backdrop than on the default view.
Settings that matter
| Setting | What it does | Typical use |
|---|---|---|
| Smooth | Rounds jagged selection corners | 2 to 5 for most subjects. High values destroy detail. |
| Feather | Blurs the whole edge evenly | 0 to 1 px for sharp photos. Soft or out-of-focus subjects can take more. |
| Contrast | Hardens the feathered edge | Raise slightly to counter feather on clean edges. |
| Shift Edge | Moves the edge in (negative) or out (positive) | Negative values of -10% to -30% remove most background fringe. |
| Refine Edge Brush | Recalculates the edge locally | Paint over hair, fur, and semi-transparent areas. |
| Decontaminate Colors | Replaces fringe colour with nearby subject colour | Turn on for hair and soft edges. Set Amount to 50 to 100%. |
Decontaminate Colors changes pixels, so it cannot output to a plain mask. Choose New Layer with Layer Mask when you use it. Because that makes a destructive copy, keep your original layer hidden underneath.
Match the edge softness to the scene
Look at how sharp the existing edges in the background are. Zoom to 100% and find an object at a similar distance from the camera. Then compare it with your cut-out.
- If the background object has a soft edge about 2 px wide, your cut-out should have that too.
- An element that is out of focus in the scene needs a wider, softer edge than one in the focal plane.
- Motion blur in the background means the edge of your subject should smear in the same direction.
The most controllable way to soften an edge is the Properties panel for the layer mask. Select the mask thumbnail, then use:
- Feather to blur the mask edge by a chosen radius.
- Density to lower the opacity of the whole mask when you want the element to be partly see-through.
Because the feather is a mask property, you can change it later or set it back to zero.
Remove fringes and halos
Fringes are usually light (from a bright sky) or dark (from a dark room) and run along the whole outline. There are four common fixes. Try them in this order.
- Shrink the mask. In the Properties panel, use Select and Mask again, or choose Select > Modify > Contract on a mask selection by 1 to 2 px. This removes the outer ring of contaminated pixels.
- Use Layer > Matting > Defringe. This replaces edge pixels with nearby colours. Enter 1 or 2 px. It works on pixel layers, not on Smart Objects with a live mask, so apply it to a rasterized copy.
- Use Layer > Matting > Remove White Matte or Remove Black Matte. Use these when the cut-out came from a white or black background and shows a rim of that colour.
- Paint the fringe out. Make an empty layer, clip it to the element, set its blend mode to Color, and sample colour from just inside the edge. Paint along the rim with a soft brush at low opacity.
The fourth method is non-destructive and works well on edges with a strong colour spill. The Color blend mode changes hue and saturation but keeps the brightness detail of the layer beneath.
Handle hair and other fine detail
Hair is the hardest case. A selection treats each pixel as either in or out, but hair needs partial opacity.
- In Select and Mask, paint over the hair area with the Refine Edge Brush. Photoshop recalculates which pixels are hair and which are background.
- Turn on Decontaminate Colors so the hair does not carry the old background colour.
- Check the result against the new background, not the old one.
If the new background is much darker or lighter than the original, the hair will still look wrong. In that case, paint a few strands by hand. Create a layer clipped to the subject, sample a hair colour, and use a small hard brush at 1 to 3 px with Flow around 30%. A few matching strands crossing the edge do more than a perfect mask.
Use a Layer Style to check and tune the edge
Two techniques help you inspect the edge quickly.
First, put a flat colour layer under the element, then switch its colour between black, white, mid-grey, and a vivid colour such as magenta. Fringes that were invisible become obvious. Fix what you see, then delete the test layer.
Second, add a thin inner shadow or similar effect only if the scene needs it. Layer styles on a masked layer apply after the mask, so they follow the new edge. In most composites you do not need them. Add one only when you can name the real-world light behaviour it represents, such as a bright rim from a backlight.
Light wrap
In real photos, bright light behind a subject spills slightly onto its edges. This is called light wrap. It makes the edge look as though it sits inside the same air as the background.
Here is a simple Photoshop version.
- Duplicate the background layer (or the area behind the element) and place the copy above the element.
- Clip it to the element so it only affects the element's pixels.
- Apply Filter > Blur > Gaussian Blur at 15 to 40 px, depending on image size.
- Add a layer mask filled with black. Paint with a white soft brush along the edges where the background light is strongest.
- Set the blend mode to Screen or Soft Light, and reduce the opacity until the effect is subtle (10 to 30%).
Keep the wrap narrow. If the viewer can notice it as a glow, it is too strong. Light wrap is correct only where the background really is brighter than the element, such as a subject in front of a bright window or a sunset sky.
Common errors
- A glowing outline. Usually caused by a feather that is too wide, or a bright fringe that was never removed. Shift the edge inward and reduce feather.
- An edge that is too sharp compared with the scene. Check the sharpness of other objects at the same distance. Add 0.5 to 1.5 px of mask feather.
- An edge that is blurrier than the element's interior. The mask is softer than the subject. Reduce feather or raise mask contrast.
- A dark or light rim that appears only after colour matching. Your colour adjustments changed the fringe. Re-check the edge after every tonal or colour change, not just once.
- Jagged, staircase edges. The selection was made at a low zoom level or the layer was scaled up after masking. Redo the mask at the final size, or use a Smart Object so scaling happens before masking is rasterized.
- Hair that looks like a cut paper shape. The mask has no partial opacity. Use the Refine Edge Brush and paint a few strands.
A short working routine
- Mask the element on a Smart Object using Select and Mask.
- Shift the edge slightly inward and turn on Decontaminate Colors for soft edges.
- Check on black, white, grey, and magenta test layers.
- Match the softness of the edge to an object at a similar distance.
- Add a colour-blend rim fix or light wrap only where the scene calls for it.
- Recheck after tonal and colour matching.
Exercise
You cut out a person from a photo taken against a bright sky and place them in front of a dark brick wall. A thin bright outline appears around their shoulders. List two non-destructive or low-risk fixes in a sensible order, and explain why increasing the mask Feather is the wrong first move.
Show answer
First, shrink the mask edge by 1 to 2 px (Shift Edge in Select and Mask with a negative value, or Contract on the mask selection) to remove the outer ring of sky-coloured pixels. Second, paint over the remaining rim on a clipped empty layer set to the Color blend mode, sampling the shoulder colour from just inside the edge, or use Layer > Matting > Defringe on a rasterized copy. Raising Feather is the wrong first move because it only blurs the bright pixels. The halo gets wider and softer, and the subject's real edge also gets thinner, which makes the glow more obvious.
Exercise
A subject stands in front of a sunset window. After you mask them, the edge looks flat and cut out, even though the mask is clean. What technique adds the missing effect, and what settings keep it believable?
Show answer
Add light wrap. Duplicate the background, clip it above the element, blur it with Gaussian Blur at roughly 15 to 40 px, mask it with black and paint white only along the edges nearest the bright window, and set the blend mode to Screen or Soft Light at 10 to 30% opacity. It should be narrow and subtle so it reads as light spilling onto the edge, not as a visible glow.