Sub topic 8
Limiting an adjustment with its layer mask
This chapter assumes you can create an adjustment layer and edit its settings in the Properties panel. It also assumes you can pick the Brush tool and set foreground and background colors. The goal is to control where an adjustment shows up in the image, so you can brighten a face without brightening the sky behind it.
Every adjustment layer already has a mask
When you create a Levels, Curves, or Hue/Saturation layer, Photoshop adds a second thumbnail beside the adjustment icon. This is the layer mask. By default it is filled with white, which means the adjustment applies everywhere.
A layer mask is a grayscale image the same size as the document. Photoshop reads each mask pixel as a strength between 0 and 100 percent:
| Mask value | Appearance | Effect on the adjustment |
|---|---|---|
| White (255) | Fully white | Adjustment applies at full strength |
| Light gray | Between white and mid-gray | Adjustment applies mostly |
| Mid gray (128) | 50% gray | Adjustment applies at about half strength |
| Dark gray | Between mid-gray and black | Adjustment applies only slightly |
| Black (0) | Fully black | Adjustment is hidden; the original pixels show through |
The mask never changes the adjustment settings. It only decides how much of the adjusted result is blended with the unadjusted image beneath it. You can repaint the mask, soften it, or delete it, and the Levels or Curves settings stay exactly as they were.
The math behind a mask
Each pixel in the result is a weighted mix of the original value and the adjusted value, using the mask as the weight. This Python function models one 8-bit channel value:
def apply_masked(original, adjusted, mask):
"""Blend an adjusted value with the original using an 8-bit mask value."""
weight = mask / 255 # 0.0 = hidden, 1.0 = full effect
return round(original + (adjusted - original) * weight)
# A pixel of value 100 that an adjustment would raise to 160.
for mask_value in (0, 64, 128, 192, 255):
print(mask_value, apply_masked(100, 160, mask_value))The output is:
0 100
64 115
128 130
192 145
255 160A mask value of 0 returns the original, 255 returns the full adjustment, and values between give a proportional mix. This is why a soft gradient in a mask produces a smooth transition, and why a hard black-to-white edge produces a visible seam.
Two thumbnails, one selection
An adjustment layer has two targets: the adjustment itself and its mask. A thin frame around a thumbnail shows which one is active. This is the most common source of mask mistakes.
- If the frame is on the mask thumbnail, painting changes the mask.
- If the frame is on the adjustment thumbnail, the Properties panel shows the adjustment controls, and painting would have no useful effect.
An adjustment layer has no pixels of its own, so you cannot paint color onto it by accident the way you can on a normal pixel layer. The usual mistake is painting while the wrong layer is active. For example, you may click a pixel layer below, paint, and then wonder why the mask did not change. Click the mask thumbnail first, then paint.
The mask also appears as a tab in the Properties panel. Select the mask thumbnail to see its controls. They are described later in this chapter.
Painting on a mask
Masks accept only grayscale. If you paint with a color while the mask is active, Photoshop converts it to its gray equivalent. Work with black, white, and grays to stay predictable.
- Click the mask thumbnail so its frame is active.
- Press D to reset the foreground and background colors to black and white. On a mask this makes the foreground black and the background white.
- Select the Brush tool (B) with a soft round tip.
- Paint with black to hide the adjustment in an area.
- Press X to swap colors, then paint with white to restore the adjustment.
Brush opacity and flow control how much gray each stroke adds. A brush at 30% opacity with black builds up the hiding effect gradually, so repeated strokes darken the mask step by step. This is useful for subtle edits such as burning back a bright area.
Brush hardness controls the edge. A soft brush produces a gradual falloff, which usually looks natural. A hard brush gives a crisp boundary. Use hard edges only where the real subject has a sharp edge.
Starting from an inverted mask
Sometimes it is easier to start with the adjustment hidden and paint it in. With the mask active, press Ctrl+I (Windows) or Cmd+I (macOS) to invert it, turning white to black. The adjustment disappears completely. Painting with white then reveals it only where you want it.
Choose the starting point by how much of the image needs the change:
- If most of the image needs the adjustment, keep the white mask and paint black over exceptions.
- If only a small region needs it, invert to black and paint white onto that region.
The second approach avoids overshooting, because the adjustment is visible only where you deliberately add it.
Creating the mask from a selection
If you have an active selection when you create the adjustment layer, Photoshop builds the mask from it. The selected area becomes white and the rest becomes black. This is a quick way to isolate a subject you have already selected. The resulting mask is an ordinary mask, and you can keep refining it by painting.
You can also go the other way. Hold Ctrl (Windows) or Cmd (macOS) and click a mask thumbnail to load the mask as a selection. This helps you reuse a good mask on another adjustment layer.
Seeing what the mask is doing
A mask can be hard to judge from its tiny thumbnail. Photoshop offers several ways to inspect it:
- Alt-click (Windows) or Option-click (macOS) the mask thumbnail to view the mask as a full-size grayscale image. Repeat the click to return to the normal view.
- Press \\ (backslash) to show the mask as a red overlay on top of the image. Red marks the hidden (black) areas. Painting while the overlay is on lets you see the image and the mask together.
- Shift-click the mask thumbnail to turn the mask off temporarily. A red X appears across the thumbnail. The adjustment then applies everywhere, which helps you check how much the mask is changing the result. Shift-click again to turn it back on.
Refining the mask in the Properties panel
With the mask thumbnail selected, the Properties panel shows controls that change the whole mask without repainting:
- Density scales how strongly black areas hide the adjustment. At 100% black hides fully. Lowering it lets some of the adjustment through the black areas, which is a quick way to weaken a mask's effect without redoing it.
- Feather blurs the mask edges. This softens a transition after you have made a selection-based mask. Increase it until the edge no longer looks cut out.
- Invert flips black and white, the same as the keyboard shortcut.
- Select and Mask opens a workspace for improving edges on selection-based masks. It is useful for hair and other fine detail.
Density and Feather are edits to the mask as a whole. Prefer them over repainting when you only need to make the effect weaker or softer.
Common errors
Painting on the wrong target. If strokes seem to do nothing, check the frame around the thumbnails. The mask must be active.
Painting with a nonzero opacity and expecting full black. A brush at 50% opacity leaves gray, so the adjustment is only half hidden. Check opacity and flow when the result looks incomplete.
Visible halos around edges. A hard-edged mask on a soft-edged subject leaves a bright or dark outline. Apply some Feather, or paint along the edge with a soft brush at low opacity.
Mask and layer out of sync. On a normal pixel layer, a chain icon links the layer to its mask so they move together. An adjustment layer has no pixels to shift, so this seldom causes trouble. But if you move the layer content or the mask separately on a pixel layer with a mask, the two will drift apart.
Forgetting a mask exists. If an adjustment seems to affect only part of the image, an old mask may be limiting it. Shift-click the mask to disable it, or Alt/Option-click to view it.
Where this leads
A mask on its own limits an adjustment to areas you choose. Later chapters build on this. The next chapter shows how to clip an adjustment to a single layer instead of drawing a mask. The chapter after that covers painted and gradient masks in more detail for local adjustments.
Exercise
An adjustment layer's mask is white, and you paint over a region with black at 50% brush opacity in a single stroke. A pixel's original value is 100 and the full adjustment would make it 160. What value does that pixel have in the final image, and why? Assume the stroke produces a mask value of 128.
Show answer
About 130. A single 50% opacity black stroke over white leaves a mask value near 128, which is a weight of about 0.5. The result is 100 + (160 - 100) × 0.5 = 130. The pixel gets half of the adjustment.
Exercise
You created a Curves adjustment layer to brighten a small face in a large photograph. Which mask workflow limits the change to the face with the least risk of brightening other areas, and which key combination do you use to start it?
Show answer
Invert the mask so it is black and the adjustment is hidden everywhere. Use Ctrl+I (Windows) or Cmd+I (macOS) with the mask thumbnail active. Then paint with white over the face using a soft brush, so the adjustment appears only there.