Sub topic 10
Local adjustments: painting and gradient masks
This chapter assumes you can create an adjustment layer, you know that a layer mask hides or reveals the layer's effect (white reveals, black hides, gray partly reveals), and you can read a histogram. It also assumes you know how to clip an adjustment to a single layer. Here you will use that mask machinery to change one part of a picture without touching the rest.
What "local" means
A global adjustment applies to every pixel in the image. A local adjustment applies strongly in one area and fades to nothing elsewhere. The usual reasons are:
- A sky is correct but the foreground is too dark.
- A face needs a small lift while the background should stay put.
- One object has a color problem that the rest of the frame does not share.
The mechanism is always the same. An adjustment layer computes a changed version of the image below it. The layer mask then decides, pixel by pixel, how much of that change is used. A mask value of 0 (black) shows none of the change, 255 (white) shows all of it, and anything in between blends the two.
The blend is a weighted average. The sketch below shows what happens to one channel value.
def apply_with_mask(original, adjusted, mask):
"""Blend one 8-bit channel value using an 8-bit mask value.
mask = 0 -> original pixel (adjustment hidden)
mask = 255 -> adjusted pixel (adjustment fully visible)
"""
weight = mask / 255
return round(original * (1 - weight) + adjusted * weight)
print(apply_with_mask(100, 180, 0)) # 100
print(apply_with_mask(100, 180, 255)) # 180
print(apply_with_mask(100, 180, 128)) # about halfway: 140Every technique in this chapter is a way of producing a useful grayscale mask. Painting and gradients are the two most common ways.
Two ways to build the mask
You can start from two different mask states, and the choice changes your workflow.
| Starting state | How to get it | Then you | Best when |
|---|---|---|---|
| White mask (effect everywhere) | The default for a new adjustment layer | Paint black or use a black-to-transparent gradient to remove the effect | The change should cover most of the image |
| Black mask (effect nowhere) | Press Cmd/Ctrl+I with the mask selected, or hold Alt/Option while clicking the new-adjustment button | Paint white to add the effect | The change is small and specific |
Starting from a black mask is often safer for small targets. You can see the effect grow as you paint, and you cannot accidentally brighten the whole image.
Painting a mask with the Brush tool
Painting is the most flexible method. You select the mask thumbnail and paint on the image with the Brush tool (B). Photoshop paints on the mask, not on the picture, because the mask is the active target.
Steps
- Create the adjustment layer, for example a Curves layer, and set it to the look you want in the area you care about. Judge the setting on that area only, and ignore the rest of the picture for now.
- Click the layer mask thumbnail in the Layers panel. A thin outline around the thumbnail confirms it is active. If the outline is on the layer's icon instead, you would paint on the wrong target.
- Invert the mask to black (Cmd/Ctrl+I) if you want to paint the effect in.
- Press D to reset the foreground and background colors to black and white. Press X to swap them.
- Choose the Brush tool and paint. White adds the effect, black removes it.
Brush settings that matter
- Hardness. A hard brush leaves a sharp edge in the mask, which looks like a cut-out. For most local work, use a hardness of 0% to 30% so the edge fades.
- Opacity. This limits how strong each stroke is. Set it to 10% to 30% and build up the effect with repeated strokes. Overlapping strokes add up, so you can shape the result gradually.
- Flow. This controls how fast paint accumulates within a single stroke. For mask work, lowering opacity is usually easier to reason about.
- Size. Press the left and right bracket keys to shrink or enlarge the brush.
Painting precisely with a selection
For an object with a clear edge, make a selection first (Quick Selection, Select Subject, Pen tool path converted to a selection). If a selection is active when you create the adjustment layer, Photoshop builds the mask from it automatically. The selected area becomes white and the rest black.
A selection gives a hard edge by default. Soften it before or after you create the mask:
- Before: Select > Modify > Feather.
- After: select the mask, then in the Properties panel, raise the Feather value of the Masks section. This blurs the mask without re-making the selection, and you can change it any time.
Common painting mistakes
- Painting on the wrong thing. If the brush is painting color onto the picture, you selected a pixel layer or the layer icon. Click the mask thumbnail first.
- Hard edges and halos. A bright halo around a subject usually means the mask edge is too sharp or slightly too large. Lower the brush hardness or add Feather.
- Over-strong adjustments hidden by a mask. If you push an adjustment too far and then mask it, the edge between treated and untreated areas looks abrupt. Use a milder setting with a softer mask.
- Lost track of the mask. Press the backslash key (\\) to show the mask as a red overlay on the image, or Alt/Option-click the mask thumbnail to view the mask alone in grayscale. Both views help you find missed spots.
Gradient masks
A gradient mask fades the effect smoothly across the frame. It suits changes that follow a gradual transition, such as darkening a bright sky toward the top while leaving the horizon alone.
Steps
- Create the adjustment layer and set the look for the area to be treated.
- Click the layer mask thumbnail.
- Choose the Gradient tool (G) and open the gradient picker in the options bar. Pick Foreground to Background or Black, White. Set the gradient shape to Linear.
- Press D so the colors are black and white.
- Drag across the image. The drag start sets where the mask is fully one color, and the drag end sets where it is fully the other. Between those points the mask ramps from black to white.
- Hold Shift while you drag to constrain the line to a perfectly vertical, horizontal, or 45-degree angle.
A longer drag makes a softer transition. A shorter drag makes a tighter one. If the horizon is not level, drag at a slight angle to match it.
Linear and radial gradients
- Linear gradients work for skies, floors, and any edge-to-edge falloff.
- Radial gradients work for vignettes and for lifting a single area, like a face. Drag from the center outward. With the Reverse option, you can choose whether the center is white (effect) or black (no effect).
Editing a gradient later
Once you release the mouse, the gradient is baked into the mask as pixels. You can undo, or drag a new gradient over it. To combine two gradients without erasing the first, change the Gradient tool's mode in the options bar from Normal to Darken or Lighten, as the mask would otherwise be overwritten. Darken keeps the darker mask value, so black areas stay black. Lighten keeps the lighter value.
Combining painting and gradients
Real images often need both. A typical sequence for a landscape:
- Add a Curves adjustment layer that darkens the sky.
- Drag a gradient on its mask so the effect fades out at the horizon.
- Paint black on the mask where the gradient darkens a mountain or building that should stay as it was. Use a small, soft brush.
The following diagram shows the order of decisions.
Refining a mask with the Properties panel
Select the mask thumbnail and open the Properties panel. The Masks section has controls that apply to the whole mask without repainting it:
- Density scales the mask's overall strength. At 50%, black stays black but white becomes a half-strength reveal. This works like an opacity control for the mask.
- Feather blurs the mask edge by a radius in pixels.
- Invert swaps black and white.
Use Density when the effect is right in shape but too strong overall. Use the layer's Opacity instead if you want to weaken the adjustment as a whole. The two give similar results for most masks, but Density keeps the mask intact for later editing, and Opacity affects the whole layer.
Edge cases and gotchas
- Banding in smooth gradients. An 8-bit image has only 256 levels per channel. A strong adjustment faded across a large clean sky can show visible bands. Working in 16-bit mode (Image > Mode > 16 Bits/Channel) gives the adjustment more room, and adding a small amount of noise (Filter > Noise > Add Noise) can hide any remaining bands.
- Masks do not follow moved pixels. A mask is linked to its layer by a small chain icon between the thumbnails. On an adjustment layer, the mask covers the canvas. If you reposition or resize image layers underneath, the mask does not follow them. Re-paint or move the mask by unlinking it and adjusting it by hand.
- Clipped adjustments and masks. When an adjustment is clipped to one layer, its mask still controls its own strength, and the clipping base layer limits where it can appear. Pixels that are transparent on the base layer show no effect at all, whatever the mask says.
- Selecting a mask edit versus a selection. Loading a mask as a selection (Cmd/Ctrl-click the mask thumbnail) is a fast way to copy one mask's shape to another adjustment layer, then fill with white or black.
- Duplicating a mask. Alt/Option-drag a mask thumbnail onto another layer to copy it. Add Cmd/Ctrl+I to invert the copy when you need the opposite area.
- Large strokes on a mask drawn too quickly. If a brush stroke looks jagged, enable stroke Smoothing in the options bar.
Checking your work
Always check a local adjustment in three ways:
- Toggle the adjustment layer's eye icon on and off. The change should look natural in the treated area and there should be no visible border.
- View the mask alone (Alt/Option-click the thumbnail) and look for stray gray patches, hard cut lines, and missed spots.
- Zoom to 100% and look along mask edges for halos or color fringes.
Summary of the technique
A local adjustment is an ordinary adjustment layer plus a grayscale mask. Choose the mask's starting color by how much of the image should change. Build it with a gradient for smooth falloffs, a selection for defined objects, and a soft, low-opacity brush for everything else. Refine with Feather and Density, and check the mask in grayscale before you finish.
Exercise
You have a Curves layer that brightens a dark face in a portrait. After you paint on its white mask with a black brush, you see a bright outline around the head. Name two causes and a fix for each.
Show answer
First, the brush edge is too hard, so the mask has a sharp border. Fix it by lowering brush hardness and repainting the border with a soft brush at low opacity. Second, the mask edge sits slightly outside the head, so the brightening reaches the background. Fix it by raising the mask's Feather in the Properties panel, or by painting black along the boundary to pull the mask back inside the subject. Viewing the mask in grayscale (Alt/Option-click the thumbnail) shows which cause applies.
Exercise
A landscape has a bright sky and a correctly exposed foreground. Describe how to darken only the sky with one adjustment layer and a gradient mask, including the tool settings, and how to protect a tree line that rises into the sky.
Show answer
Create a Curves (or Levels) layer and pull the tones down until the sky looks right. Click its layer mask thumbnail and press D to reset the colors to black and white. Choose the Gradient tool with a Linear, Foreground to Background gradient. Make the mask white at the top and black at the horizon by dragging from the horizon upward with the colors arranged so the top is white, or drag the other way and invert the mask. Hold Shift to keep the drag vertical. Then take a small soft Brush at low opacity and paint black on the mask over the tree line so the darkening does not reach it.