Selecting by Color

In addition to giving you tools to select areas by shape, Photoshop lets you select areas by color. This option is helpful when you want to select a chunk of an image that's fairly uniform in color, like someone's skin, the sky, or the paint job on a car. Photoshop has lots of tools to choose from, and in the next several pages, you'll learn how to pick the one that best suits your needs.

The Quick Selection Tool

The Quick Selection tool is shockingly easy to use and lets you create complex selections with a few strokes of an adjustable brush. As you paint with the Quick Selection tool, your selection expands outward to encompass pixels similar in color to the ones you're brushing across. It works insanely well if there's a fair amount of contrast between what you want to select and everything else. This tool lives in the same toolset as the Magic Wand (The Magic Wand), as you can see in Figure 4-7.

When you activate the Quick Selection tool, the Options bar sports buttons that let you create a new selection and add to or subtract from the current selection.You can press the W key to activate the Quick Selection tool. To switch between it and the Magic Wand, press Shift-W.

Figure 4-7. When you activate the Quick Selection tool, the Options bar sports buttons that let you create a new selection and add to or subtract from the current selection. You can press the W key to activate the Quick Selection tool. To switch between it and the Magic Wand, press Shift-W.

To use this wonderfully friendly tool, click anywhere in the area you want to select or drag the brush cursor across it, as shown in Figure 4-8. When you do that, Photoshop thinks for a second and then creates a selection based on the color of the pixels you clicked or brushed across. The size of the area Photoshop selects is proportional to the size of the brush you're using: a larger brush creates a larger selection. You can adjust the Quick Selection tool's brush size just like any other brush: by choosing a new size from the Brush Preset picker in the Options bar, or by using the keyboard shortcut discussed in the Tip on Tip. (Chapter 12 covers brushes in detail.) For the best results, use a hard-edged brush to produce defined edges (instead of the slightly transparent edges produced by a soft-edge brush) and turn on the Auto-Enhance setting shown in Figure 4-7 and discussed in the box on Smart Auto-Enhancing.

If the color of the objects you want to select differs greatly from the color of their background, like these chili peppers, take the Quick Selection tool for a spin. With this tool activated, you can either single-click the area you want to select or drag your cursor (circled) across the area as if you were painting. When the tool is in "Add to selection" mode, you see a tiny + sign inside the cursor, as shown here. This mode lets you add to an existing selection or make multiple selections.

Figure 4-8. If the color of the objects you want to select differs greatly from the color of their background, like these chili peppers, take the Quick Selection tool for a spin. With this tool activated, you can either single-click the area you want to select or drag your cursor (circled) across the area as if you were painting. When the tool is in "Add to selection" mode, you see a tiny + sign inside the cursor, as shown here. This mode lets you add to an existing selection or make multiple selections.

When you activate the Quick Selection tool, the Options bar offers three modes (see Figure 4-7):

  • New selection. When you first grab the Quick Selection tool, it's automatically set to create a brand-new selection, which is helpful since creating a new selection is sort of the whole point.

  • Add to selection. Once you've clicked or made an initial brushstroke, the Quick Selection tool automatically goes into "Add to selection" mode (indicated by the tiny + sign inside the cursor, as shown in Figure 4-8). Now Photoshop adds any additional areas you brush over or click to your current selection. If you don't like the selection Photoshop has created and want to start over, press ⌘-Z (Ctrl+Z on a PC) to undo it, or click the Options bar's "New selection" button and then brush across the area again. (The old selection disappears as soon as you start to make a new one.) To get rid of the marching ants altogether, choose Select→Deselect.

  • Subtract from selection. Adding to a selection can make Photoshop select more than you really want it to. If you have this problem, click the "Subtract from selection" button (a tiny – sign appears in your cursor) and then simply paint across the area you don't want selected to make Photoshop exclude it.

    Note

    To get the most out of the Quick Selection tool, you'll probably need to do a fair amount of adding to and subtracting from your selections. Keyboard shortcuts can help speed up the process: Press and hold the Shift key to enter "Add to selection" mode. Press and hold the Option key (Alt on a PC) to enter "Subtract from selection" mode. If these shortcuts sound familiar, they should—they're identical to the marquee tools' keyboard shortcuts.

  • Brush Size. Use a larger brush to select big areas and a smaller brush to select small or hard-to-reach areas. As explained earlier, you'll get better results with this tool by using a hard-edged brush instead of a soft-edged one.

    Tip

    You can change a brush cursor's size by dragging: press Ctrl-Option and drag to the left or right (right-click+Alt on a PC). You can also decrease the brush size by pressing the left bracket key ([ ) or increase it by pressing the right bracket key ( ]).

  • Sample All Layers. This setting is initially turned off, which means Photoshop examines only the pixels on the active layer (the one that's selected in your Layers panel). If you turn on this setting, Photoshop examines the whole enchilada—everything in your document—and grabs all similar pixels no matter which layer they're on.

  • Auto-Enhance. Because the Quick Selection tool makes selections extremely fast, their edges can end up looking blocky and imperfect. To tell Photoshop to take its time and think more carefully about the selections it makes, turn on the Options bar's Auto-Enhance checkbox. This feature gives your selections smoother edges, but if you're working with a really big file, you could do your taxes while it's processing. The box below has tips for using this feature.

The Magic Wand

The Magic Wand lets you select areas of color by clicking (rather than dragging). It's in the same toolset as the Quick Selection tool, and you can grab it by pressing Shift-W (it looks like a wizard's wand, as shown back in Figure 4-7). Use the Magic Wand to select solid-colored backgrounds or large bodies of similar color, like a cloudless sky, with just a couple of clicks. The Quick Selection tool, in contrast, is better at selecting objects rather than big swaths of color.

When you click once with the Magic Wand in the area you want to select, Photoshop magically (hence the name) selects all the pixels on the currently selected layer that are both similar in color and touching one another (see Expanding your selection to learn how to tweak this behavior). If the color in the area you want to select varies a bit, Photoshop may not select all of it. In that case, you can add to the selection either by pressing and holding the Shift key as you click nearby areas or by modifying the Magic Wand's tolerance in the Options bar as described later in this section and shown in Figure 4-9. To subtract from your selection, just press and hold the Option key (Alt on a PC) while you click the area you don't want included.

With its tolerance set to 32, the Magic Wand did a good job of selecting the sky behind downtown Dallas.You've got several ways to select the spots it missed like the area circled at the bottom left: You can add to the selection by pressing the Shift key as you click in that area, increase the tolerance setting in the Options bar and then click the sky again to create a new selection, or skip to page 154 to learn how to expand your selection with the Grow and Similar commands.

Figure 4-9. With its tolerance set to 32, the Magic Wand did a good job of selecting the sky behind downtown Dallas. You've got several ways to select the spots it missed like the area circled at the bottom left: You can add to the selection by pressing the Shift key as you click in that area, increase the tolerance setting in the Options bar and then click the sky again to create a new selection, or skip to page 154 to learn how to expand your selection with the Grow and Similar commands.

When you activate the Magic Wand, the Options bar lets you adjust the following settings:

  • Tolerance. This setting controls the Magic Wand's sensitivity—how picky the tool is about which pixels it considers similar in color. If you increase this setting, Photoshop gets less picky (in other words, more tolerant) and selects every pixel that could possibly be described as similar to the one you originally clicked. If you decrease this setting, Photoshop gets pickier and selects only pixels that closely match the original.

    Out of the box, the tolerance is set to 32, but it can go all the way up to 255. (If you set it to 0, Photoshop selects only pixels that exactly match the one you clicked; if you set it to 255, the program selects every color in the image.) It's usually a good idea to keep the tolerance set fairly low (somewhere between 12 and 32); you can always click an area to see what kind of selection you get, increase the tolerance if you need to, and then click the area again (or add to the selection using the Shift key, as described above).

    Note

    When you adjust the Magic Wand's tolerance, Photoshop won't automatically rethink your current selection. You have to click the area again to make Photoshop recalculate its selection.

  • Anti-alias. Leave this setting turned on to make Photoshop soften the edges of your selection ever so slightly. If you want a super-crisp edge, turn it off.

  • Contiguous. You'll probably want to leave this checkbox turned on; it makes the Magic Wand select pixels that are adjacent to one another. If you turn this setting off, Photoshop goes hog wild and selects all similar-colored pixels no matter where they are.

  • Sample all layers. If your document has multiple layers and you leave this checkbox turned off, Photoshop examines only pixels on the active layer and ignores the pixels on other layers. If you turn this setting on, Photoshop examines the whole image and selects all pixels that are similar in color, no matter which layer they're on.

Expanding your selection

Sometimes the Magic Wand makes a nearly perfect selection, leaving you with precious few pixels to add to it. If this happens, it simply means that the elusive pixels are just a little bit lighter or darker in color than what the Magic Wand's tolerance setting allows for. You could Shift-click the elusive areas to add them to your selection, but the Select menu has a couple of options that can quickly expand the selection for you:

  • Choose Select→Grow to make Photoshop expand your selection to all similar-colored pixels adjacent to the selection (see Figure 4-10, top).

  • Choose Select→Similar to make Photoshop select similar-colored pixels through-out the whole image even if they're not touching the original selection (see Figure 4-10, bottom).

Note

Because both these commands base their calculations on the Magic Wand's tolerance setting (The Magic Wand), you can adjust their sensitivity by adjusting that setting in the Options bar. You also can run these commands more than once to get the selection you want.

Top: Say you're trying to select the red part of this Texas flag. After clicking once with the Magic Wand (with a tolerance of 32), you still need to select a bit more of the red (left). Since the red pixels are all touching each other, you can run the Grow command a couple of times to make Photoshop expand your selection to include all the red (right).Bottom: If you want to select the red in these playing cards (what a poker hand!), the Grow command won't help because the red pixels aren't touching each other. In that case, click once with the Magic Wand to select one of the red areas (left) and then use the Similar command to grab the rest of them (right). Read 'em and weep, boys!

Figure 4-10. Top: Say you're trying to select the red part of this Texas flag. After clicking once with the Magic Wand (with a tolerance of 32), you still need to select a bit more of the red (left). Since the red pixels are all touching each other, you can run the Grow command a couple of times to make Photoshop expand your selection to include all the red (right). Bottom: If you want to select the red in these playing cards (what a poker hand!), the Grow command won't help because the red pixels aren't touching each other. In that case, click once with the Magic Wand to select one of the red areas (left) and then use the Similar command to grab the rest of them (right). Read 'em and weep, boys!

The Color Range Command

The Color Range command is similar to the tools in this section in that it makes selections based on colors, but it's much better at selecting areas that contain lots of details (for example, the flower bunches in Figure 4-11). The Magic Wand tends to select whole pixels, whereas Color Range is more fine-tuned and tends to select more partial pixels than whole ones. This fine-tuning lets Color Range produce selections with smoother edges (less blocky and jagged than the ones you get with the Magic Wand) and get in more tightly around areas with lots of details. As a bonus, you also get a handy preview in the Color Range dialog box, showing you which pixels it'll select before you commit to the selection (unlike the Grow and Similar commands discussed on The Color Range Command).

The Color Range command is handy when you need to select an area with a lot of details, like the red and blue petals of these flowers. The image in the dialog box's preview area shows the part that Photoshop will select when you click the OK button.

Figure 4-11. The Color Range command is handy when you need to select an area with a lot of details, like the red and blue petals of these flowers. The image in the dialog box's preview area shows the part that Photoshop will select when you click the OK button.

Open the Color Range dialog box by choosing Select→Color Range, either before or after you make a selection. If you already have a selection, Photoshop looks only at the pixels within the selected area, which is helpful if you want to isolate a certain area. For example, you could throw a quick selection around the red flower shown in the center of Figure 4-11 and use Color Range's subtract from selection capabilities (explained later in this section) to carve out just the red petals. By contrast, if you want to use Color Range to help expand your selection, press and hold the Shift key while you choose Select→Color Range. If you haven't yet made a selection, Color Range examines your entire image.

Use the Select pop-up menu at the top of the Color Range dialog box to tell Photoshop which colors to include in your selection. The menu is automatically set to Sampled Colors, which lets you mouse over an image (your cursor turns into a tiny eyedropper; see Figure 4-11) and click the color you want to select. If you change the Select menu's setting to Reds, Blues, Greens, or whatever, Color Range will examine your image and grab that range of colors all by itself—once you click OK.

Note

As mentioned in the box on Selecting the Opposite, it's sometimes easier to select what you don't want in order to get the selection you need. The Color Range dialog box lets you select what you don't want by turning on the Invert checkbox.

If you're trying to select adjacent pixels, turn on Localized Color Clusters. You can tweak the area Photoshop selects by adjusting the Fuzziness setting. Its factory setting is 40, but you can change this number to anything between 0 and 200. If you increase it, Photoshop includes more colors and makes larger selections. If you lower it, Photoshop creates a smaller selection because it gets pickier about matching colors. As you move the Fuzziness slider (or type a number in the text box), keep an eye on the dialog box's preview area—all the parts of the image that Photoshop will include in your selection appear white (see Figure 4-11).

Use the eyedroppers on the dialog box's right side to add or subtract colors from your selection; the eyedropper with the tiny + sign adds to your selection and the one with the – sign subtracts from it. (Use the plain eyedropper to make your initial selection.) When you click one of the eyedroppers, mouse over to your image, and then click the color you want to add or subtract, Photoshop updates the Color Range dialog box's preview area to show what the new selection looks like. It sometimes helps to keep the Fuzziness setting fairly low (around 50 or so) while you click repeatedly with the eyedropper.

Tip

You can use the radio buttons beneath the Color Range dialog box's preview area to see either the selected area (which appears white) or the image itself. But there's a better, faster way to switch between the two views: With Selection turned on, press the ⌘ key (Ctrl on a PC) to switch temporarily to Image preview. When you let go of the key, you're back to Selection preview.

The Selection Preview pop-up menu at the bottom of the dialog box lets you display a selection preview on the image itself so that, instead of using the dinky preview in the dialog box, you can see your proposed selection right on your image. But you'll probably want to leave this menu set to None because the preview options that Photoshop offers (Grayscale, Black Matte, and so on) get really distracting!

The Background and Magic Erasers

These two tools let you erase parts of your image based on the color you touch with your cursor. You're probably thinking, "Hey, I want to create a selection, not go around erasing stuff!" And you have a valid point except that, after you've done a little erasing, you can always load that area as a selection. All you have to do is think ahead and create a duplicate layer before you start erasing, as this section explains.

Say you have an image with a decent amount of contrast between the item you want to keep and its background, like a dead tree against the sky. In that case, Photoshop has a couple of eraser tools that can help you erase the sky super fast (see Figure 4-12). Sure, you could use the Magic Wand or Quick Selection tool to select the sky and then delete or mask it (Layer Masks: Digital Masking Tape), but using the Background Eraser lets you erase more carefully around the edges and then add a layer mask to hide the rest of it.

You may never see these tools because they're hidden inside the same toolset as the regular Eraser tool. Just click and hold the Eraser tool until the little pop-up menu appears. Pick an eraser based on how you want to use it: You drag to erase with the Background Eraser (as if you were painting, which is great for getting around the edges of an object), whereas you simply click with the Magic Eraser.

Figure 4-12. You may never see these tools because they're hidden inside the same toolset as the regular Eraser tool. Just click and hold the Eraser tool until the little pop-up menu appears. Pick an eraser based on how you want to use it: You drag to erase with the Background Eraser (as if you were painting, which is great for getting around the edges of an object), whereas you simply click with the Magic Eraser.

Tip

The Eraser tool's keyboard shortcut is the E key. To switch among the various eraser tools, press Shift-E repeatedly.

The Background Eraser

This tool lets you delete an image's background by painting (dragging) across the pixels you want to delete. When you activate the Background Eraser by choosing it from the Tools panel, your cursor turns into a circle with a tiny crosshair in its center. This crosshair controls which pixels Photoshop deletes, so be extra careful and let it touch only the pixels you want to erase. Up in the Options bar, you can tweak the following settings for this tool (see Figure 4-13):

  • Brush Preset picker. This is where you choose the shape and size of your brush. For best results, stick with a soft-edged brush. Just click the down-pointing triangle next to this menu to grab one.

    Even though the Background Eraser is destructive because it erases pixels, you can use it in a nondestructive way by remembering to duplicate the soon-to-be-erased layer first. Then load the erased layer as a selection and use it as a layer mask on the original layer. As you can see here, Photoshop pays attention only to the color you touch with the crosshair in the center of the brush; even though the tree's branches are within the brush area (the circle), Photoshop deletes only the blue pixels.If you want to practice erasing this background, download DeadTree.jpg from this book's Missing CD page at www.missingmanuals.com/cds.

    Figure 4-13. Even though the Background Eraser is destructive because it erases pixels, you can use it in a nondestructive way by remembering to duplicate the soon-to-be-erased layer first. Then load the erased layer as a selection and use it as a layer mask on the original layer. As you can see here, Photoshop pays attention only to the color you touch with the crosshair in the center of the brush; even though the tree's branches are within the brush area (the circle), Photoshop deletes only the blue pixels. If you want to practice erasing this background, download DeadTree.jpg from this book's Missing CD page at www.missingmanuals.com/cds.

  • Sampling. Made up of three buttons whose icons all include eyedroppers, this setting controls how often Photoshop looks at the color the crosshair is touching to decide what to erase. If your background has a lot of color variations, leave this set to Continuous so Photoshop keeps a constant watch on what color pixels the crosshair is touching. If the color of background you're erasing is fairly uniform, change this setting to Once and Photoshop then checks the color the crosshair touches just once and resolves to erase only pixels that closely match it. If you're dealing with an image with only a small area for you to paint (like a tiny portion of sky showing through a lush tree), you can change this setting to Background Swatch, which instructs Photoshop to erase only the color of your current background color chip. To choose the color, click the background color chip at the bottom of your Tools panel (Foreground and background color chips), mouse over to your image, and then click an area whose color is similar to the color you want to erase.

  • Limits. When you first launch Photoshop, you'll find this field set to Contiguous, which means you can erase only pixels adjacent to those that you touch with the crosshair. If you want to erase similar-colored pixels elsewhere in your image (for example, the background behind a really thick tree or a bunch of flowers), change this setting to Discontiguous. Find Edges also erases adjacent pixels, but it does so while preserving the sharpness of the object's edge.

  • Tolerance. This setting works just like the Magic Wand's Tolerance setting (The Magic Wand): Choosing a lower number makes the tool pickier about the pixels it selects, whereas a higher number makes it less picky.

  • Protect Foreground Color. If you can't seem to get the Tolerance setting high enough and you're still erasing some of the area you want to keep, turning on this checkbox can help. When it's on, you can tell Photoshop which area you want to keep (the foreground) by Option-clicking (Alt-clicking on a PC) that area. If the area you want to keep is a different color in different parts of your image, you can turn this setting off or Option-click (Alt-click) to resample the foreground area.

Here's how to use the Background Eraser to erase the sky behind a dead tree without harming the original pixels, as shown in Figure 4-13:

  1. Open a photo and double-click its Background layer to make it editable (Restacking Layers) and then duplicate the Background by pressing ⌘-J (Ctrl+J on a PC).

    Since you'll add a layer mask to the original layer in the last step of this list, you need to unlock the Background to make it editable. And because you'll do your erasing on the duplicate layer, you don't need to see the original layer. Over in the Layers panel, click the little visibility eye to the left of the original layer's thumbnail to turn it off.

  2. Grab the Background Eraser tool and paint away the background.

    The Background Eraser tool is in the same toolset as the Eraser tool (see Figure 4-12). Once you've activated it, mouse over to your document and your cursor morphs into a circle with a tiny crosshair in the center. Remember that the trick is to let the crosshair touch only the pixels you want to erase (it doesn't matter what the circle part of the cursor touches, as Figure 4-13 shows). If you need to, you can increase and decrease your brush size by pressing the left and right bracket keys on your keyboard, respectively.

  3. If the tool is erasing too much or too little of your image, tweak the Tolerance setting in the Options bar (also shown in Figure 4-13).

    If an area in your image is almost the same color as the background, lower the tolerance to make the tool pickier about the colors it's erasing; that way, it erases only pixels that closely match the ones you touch with the crosshair. Likewise, if it's not erasing enough of the background, raise the tolerance to make it less picky about the pixels it zaps.

    Tip

    It's better to erase small sections at a time instead of painting around the entire object in one continuous stroke. Hold your mouse button to erase a bit of the area around the object, let go of the button, click again to erase a little more, and so on. That way, if you need to undo your erasing using the History panel (Changing How Far Back You Can Go) or the Undo command (⌘-Z; Ctrl+Z on a PC), you won't have to watch all that erasing unravel before your eyes.

  4. Once you get a clean outline around the object, switch to the regular Eraser tool (Fading Images Together) or the Lasso tool (Using the Lasso Tools) to get rid of the remaining background.

    After you erase the hard part—the area around the edges—with the Background Eraser, you can use the regular Eraser tool, set to a large brush, to get rid of the remaining background quickly. You can also use the Lasso tool to select the remaining areas and then press the Delete key (Backspace on a PC) to get rid of them.

  5. Load the erased layer as a selection and turn off its visibility.

    Over in the Layers panel, ⌘-click (Ctrl-click on a PC) the thumbnail of the layer you did the erasing work on to create a selection around the tree. When you see the marching ants, click the layer's visibility eye to turn it off.

  6. Select the original layer, turn on its visibility, and then put a layer mask over it.

    In the Layers panel, click once to select the original layer (the unlocked Background) and then click the area to the left of its thumbnail to make it visible again. While you have marching ants running around the newly erased area, add a layer mask (Layer Masks: Digital Masking Tape) to the original layer by clicking the circle-within-a-square icon at the bottom of the Layers panel.

You're basically done at this point, but if you need to do any cleanup work (if the Background Eraser didn't do a perfect job getting around the edges, say), now's the time to edit the layer mask. To edit the mask, click its layer thumbnail over in the Layers panel. Then press B to grab the Brush tool and set your foreground color chip to black (Foreground and background color chips). Now, when you brush across your image, you'll hide more of the sky. If you need to reveal more of the tree, set your foreground color chip to white, and then paint the area you want to reveal. (See Layer Masks: Digital Masking Tape for a detailed discussion of creating and editing layer masks.)

Sure, duplicating the layer you're erasing takes an extra step, but that way you're not deleting any pixels—you're just hiding them with a layer mask, so you can get them back if you want to. How cool is that?

Note

Ever heard the expression, "Out with the old and in with the new"? Well, that's sort of what happened to the Extract filter. Honestly, you're better off learning to use Photoshop CS5's enhanced Refine Edge dialog box (Creating Selections with Channels), but you can wrestle the old Extract filter back into the 32-bit version of the program if you can't live without it. Visit this book's Missing CD page at www.missingmanuals.com/cds to learn how.

The Magic Eraser

This tool works just like the Background Eraser except that, instead of a brush cursor that you paint with, you get a cursor that looks like a cross between the Eraser tool and the Magic Wand. Just as the Magic Wand can select color with a single click, the Magic Eraser can zap color with a single click, so it's great for erasing big areas of solid color instantly. Since this tool is an eraser, it really will delete pixels, so you'll want to duplicate your Background layer before using it.

You can alter the Magic Eraser's behavior by adjusting these Options bar settings:

  • Anti-alias. Turning this checkbox on makes Photoshop slightly soften the edges of your selection.

  • Contiguous. If you want to erase pixels that touch each other, leave this checkbox turned on. If you want to erase similar-colored pixels no matter where they are in your image, turn it off.

  • Sample All Layers. If you have a multilayer document, you can turn on this checkbox to make Photoshop look at the pixels on all the layers instead of just the active layer.

  • Opacity. If you want to control how strong the Magic Eraser is, you can enter a value (as a percent) here. For example, entering 50 makes it wipe away 50 percent of the image's opacity, entering 100 removes the image entirely, and so on.

Get Photoshop CS5: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.