Sub topic 10
Keeping the result: layer masks and saved selections
A selection disappears the moment you deselect or make a new one. This chapter covers the two ways to keep your work: a layer mask, which stores the selection on a layer, and a saved selection, which stores it as a channel in the document.
This chapter assumes you can make selections with the tools from earlier chapters. You should also know the Layers panel and how Select and Mask hands off its result. Basic familiarity with the Channels panel helps, but it is explained as it comes up.
Why a selection is not enough
A selection is temporary. It is a boundary held in memory, and it has two weaknesses:
- Undo history is finite, and closing the file discards the selection.
- If you use the selection to delete pixels, the deletion is permanent. You can't recover the edge later.
Photoshop represents a selection internally as a grayscale image. White pixels are fully selected, black pixels are unselected, and gray pixels are partially selected. This is why feathering produces soft edges: it creates gray values along the boundary.
A layer mask and a saved selection are both stored copies of that grayscale image. They differ in where they live and what they do.
| Storage | Where it lives | What it does by itself | Typical use |
|---|---|---|---|
| Layer mask | Attached to one layer | Hides or reveals that layer's pixels right away | Cutting out a subject without deleting anything |
| Saved selection (alpha channel) | In the document, in the Channels panel | Nothing until you load it | Reusing a selection on many layers or later sessions |
Layer masks: the model
A layer mask is a grayscale image attached to a layer. It controls the layer's visibility pixel by pixel:
- White in the mask shows the layer's pixels.
- Black in the mask hides them.
- Gray shows them partially, in proportion to the gray level.
The hidden pixels are not deleted. They are still in the layer, so you can paint the mask white to bring them back. This is what "non-destructive" means here.
Making a mask from a selection
There are three common ways to do it. Before you start, check that you are on a regular layer. The Background layer can't take a mask in the usual way, so convert it first by double-clicking it in the Layers panel and clicking OK.
- Make the selection and select the layer in the Layers panel.
- Click the Add Layer Mask button at the bottom of the panel. It looks like a rectangle with a circle inside.
- The selected area becomes white in the mask and everything else becomes black.
The result is that the selected area stays visible and the rest of the layer is hidden.
To do the reverse, hold Alt (Windows) or Option (Mac) while clicking the button. The selection becomes black and the unselected area becomes white, so the selected area is hidden. This is useful when you selected the thing you want to remove, such as a sky.
The same two options appear in the menu as Layer > Layer Mask > Reveal Selection and Layer > Layer Mask > Hide Selection.
Without a selection
If nothing is selected, the button creates an all-white mask, which hides nothing. The button's Alt/Option variant creates an all-black mask, which hides everything. You then paint white where you want the layer to appear. This works well when you want to build up the visible area gradually with a brush.
From Select and Mask
In the Select and Mask workspace, the Output To menu in the Output Settings section lets you choose the result directly:
| Output To option | Result |
|---|---|
| Selection | Returns to the document with a refined selection |
| Layer Mask | Adds a mask to the current layer |
| New Layer | Copies the selected pixels to a new layer |
| New Layer with Layer Mask | Duplicates the layer and adds a mask to the copy |
| New Document | Creates a new file with the cutout |
| New Document with Layer Mask | Creates a new file with the cutout and its mask |
For most cutouts, New Layer with Layer Mask is the safest choice. The original layer stays untouched under the copy. If the Decontaminate Colors option is on, Photoshop can't write the result back to the original layer, so it requires one of the New Layer or New Document outputs.
Reading and editing the mask
Once a mask exists, you work on it as an image:
- Click the mask thumbnail to make it the active target. A border appears around the thumbnail. Click the layer thumbnail to go back to editing pixels. Many mask errors come from painting on the wrong one.
- Press D to reset the foreground and background colors to black and white, and press X to swap them.
- With the Brush tool, paint black to hide and white to reveal. Use a soft brush for blended edges and a hard brush for clean ones.
- Alt/Option-click the mask thumbnail to view the mask itself in the document window. Click again to return.
- Press the backslash key (\) to show the mask as a red overlay on the image. This is the best view for finding gaps along an edge.
- Shift-click the thumbnail to turn the mask off temporarily. A red X appears over it. Shift-click again to turn it back on.
The Properties panel
With a mask thumbnail selected, the Properties panel (Window > Properties) shows controls for it:
- Density sets how strongly the mask hides. At 100% black means fully hidden. At lower values the black areas let some of the layer through.
- Feather blurs the mask edge. Because it works on the mask, you can change it later, unlike feathering a selection before use.
- Select and Mask... reopens the refinement workspace on this mask.
- Load selection from mask converts the mask back into a selection.
- Apply mask deletes the hidden pixels and removes the mask. This is destructive, so avoid it until the edit is final.
- Invert swaps black and white in the mask.
Link between layer and mask
A small chain icon sits between the layer thumbnail and the mask thumbnail. While it is linked, moving the layer moves the mask with it. Click the chain to unlink. Then you can slide the layer content under a fixed mask. This is how you reposition a photo inside a mask-shaped frame.
Turning a mask back into a selection
A mask is also a selection source. Ctrl-click (Windows) or Cmd-click (Mac) the mask thumbnail to load it as a selection. Gray areas load as partial selections, so a feathered edge stays feathered.
You can combine the loaded mask with an existing selection by adding modifier keys:
| Keys while clicking the thumbnail | Operation |
|---|---|
| Ctrl/Cmd | Replace the current selection |
| Ctrl/Cmd + Shift | Add to the current selection |
| Ctrl/Cmd + Alt/Option | Subtract from the current selection |
| Ctrl/Cmd + Shift + Alt/Option | Intersect with the current selection |
These match the new, add, subtract, and intersect modes from earlier in the tutorial. The same clicks work on a layer's own thumbnail, where they load the layer's transparency as a selection.
Saved selections
A saved selection is stored as an alpha channel. An alpha channel is a grayscale channel that is not part of the image's color. It doesn't change how the image looks, and you can see it in the Channels panel.
To save the current selection:
- Choose Select > Save Selection.
- In the dialog, leave Document set to the current file and Channel set to New.
- Type a descriptive name, such as
subject-hairorsky. - Click OK.
The name matters. Channels called "Alpha 1" and "Alpha 2" become impossible to tell apart after a few weeks.
To use it, choose Select > Load Selection. Pick the channel by name. The dialog has two useful controls:
- Invert loads the opposite area, so a saved sky becomes a selected foreground.
- Operation says how the loaded selection combines with any existing one: New Selection, Add to Selection, Subtract from Selection, or Intersect with Selection.
If you pick an existing channel in the Save Selection dialog, the Operation section lets you replace that channel or combine the new selection with it. This allows you to build a complex selection in stages and store each stage.
You can also Ctrl/Cmd-click a channel in the Channels panel to load it, with the same modifier keys as above.
Editing a saved selection
Because an alpha channel is just a grayscale image, you can click it in the Channels panel and paint on it with the Brush tool. White adds to the selection and black removes. The Levels or Curves adjustments (Image > Adjustments) also work on a channel. Tightening the contrast can clean up a rough edge before you load it. Click the RGB composite channel afterward to return to normal editing.
File format limits
Saved selections are only kept in formats that support extra channels. PSD, PSB, and TIFF keep them. JPEG does not. If you save a copy as JPEG, the channels are dropped, so keep a layered PSD as your working file.
Each alpha channel also adds to the file size, roughly the size of one extra grayscale layer. For a large document with many channels, delete the ones you no longer need by dragging them to the trash icon in the Channels panel.
Choosing between a mask and a saved selection
Use a layer mask when the goal is a visible edit: a cutout, a blend between two images, or a masked adjustment layer. Adjustment layers such as Curves and Hue/Saturation get a mask automatically when you create them with a selection active, which limits the adjustment to that area.
Use a saved selection when you need the area itself rather than an effect. Examples are:
- A selection that took an hour to build, and which you want to keep as a backup.
- A region you will need on several different layers.
- A starting point you plan to refine in more than one way.
The two work together. A common approach is to save the selection first, then add the mask. If the mask goes wrong, you can load the saved version and start again without redoing the selection.
Common problems
- The Add Layer Mask button does nothing useful on the Background layer. Convert it to a regular layer first.
- Painting has no visible effect. You are probably painting on the layer thumbnail, not the mask, or the foreground color is not black or white.
- The cutout has a bright halo. Fringe pixels from the old background are still in the layer. Reopen Select and Mask from the Properties panel and use Shift Edge or Decontaminate Colors, then output to a new layer with a mask.
- The edge is too hard or too soft. Adjust Feather in the Properties panel instead of redoing the selection. This is the advantage of masking over feathering a selection beforehand.
- A saved selection is missing after export. The file was saved in a format without channel support, such as JPEG.
- The mask moves out of position. The layer and mask were unlinked, or only one was moved. Click the chain icon to relink, then use Undo and try again.
Exercise
You selected a person with Object Selection and clicked Add Layer Mask, but you realize you wanted to remove the person and keep the background. You have not changed anything else. What are two ways to fix it?
Show answer
Click the mask thumbnail and choose Invert in the Properties panel (or press Ctrl/Cmd+I). The black and white areas swap, so the person is hidden. Alternatively, delete the mask, reselect the person, and Alt/Option-click the Add Layer Mask button (or choose Layer > Layer Mask > Hide Selection). The first way is quicker because it keeps any refinement you already made to the mask.
Exercise
You spent a long time building a selection of a model's hair. You want to keep it for later, and you also want to reuse it on a second layer today. What do you do, and what file format must you use to keep it between sessions?
Show answer
Choose Select > Save Selection, give the channel a clear name such as "hair", and click OK. On the second layer, choose Select > Load Selection, pick "hair" from the Channel menu, and click OK (or Ctrl/Cmd-click the channel in the Channels panel). To keep the saved selection between sessions, save the file as PSD, PSB, or TIFF. JPEG discards alpha channels.