Computer Graphics

Basics: Selection

We already know that layers separate different image elements. We already know that masks separate visible and invisible parts of a layer. The third tool to separate parts of image from other parts is selection.

In this tutorial, we will be replacing a pale sky from an overexposed photograph by a nice blue sky with some clouds. And selection will be introduced throughout the process.

1. Download the photo and find a photo of sky

This is the photo we'll be working with. It's Elgin cathedral in Scotland and there's rarely good weather in Scotland. Therefore the sky above the cathedral is very dull. Also, google some nice sky photo we'll be putting in the cathedral image. (Or download the one I found:)

Paste the sky as a new layer into the cathedral photo and name the two layers Cathedral and Sky.

Change the order of the layer so that the Cathedral layer is above the Sky layer.

2. Mask out the pale sky (or not yet)

To remove the pale sky and make the underlying blue sky see through the Cathedral layer, we will create a layer mask for the Cathedral layer. We would now select the Paintbrush tool and paint black in the window area to hide the pale sky. This is very laborious and not much fun. Don't do it. There's a better way.

3. Select the pale sky

Notice how the pale sky is almost the same color everywhere. That's a thing we can take advantage of and save us some time.

Pick the Fuzzy select tool (U) which looks like a magic wand. (In fact, this tool is called magic wand in Photoshop). The fuzzy select tool selects an area of similar colors. The limit of what counts as similar is called threshold and you find it in the tool's options panel. Set the threshold to 105.

Make sure your current layer is Cathedral and that you have the layer active, not it's mask. Click with the fuzzy select tool into the pale window area of the Cathedral. A selection will be created, as you can see by the 'marching ants' border around the border of the window.

4. What is a selection anyway?

Selection is an area which limits all actions into it. If you have a selection active, all actions in the image are restricted to the selection. If you have the window area selected, try painting into it with the paintbrush. You will never cross the border of the selection with your paintbrush. See?:

Selection is not bound to any layer or mask. You can e.g. create a selection by fuzzy select tool in one layer then use the same selection for restricting actions in another layer or mask. There is at most one selection active for the whole image document, for all layers and all masks.

5. Use the selection to mask out the window

With the selection still active, select the mask of the cathedral layer. We will be painting black in the mask now and our painting will not cross the selections's border. We won't have to worry about painting all the delicate details of the gothic window.

Tip: You can save even more time if you don't use paintbrush tool to paint black into the mask but instead use the Bucket fill tool (Shift+B). This tool fills whole areas with the active color. Select the tool, select the mask and click into the selected area in the window. The mask will fill the area with black.

Once the window area in the mask is painted (or filled) with black, the blue sky from the underlying layer will start to peek through the window:

Repeat the fuzzy selection and black-painting for the remaining areas. Remember to perform the fuzzy selection in the layer and the painting in the mask!

This is the final result:

There are other tools for selection also: rectangular, circular or free select tool. And you can also shrink or grow the active selection. We'll get to that in future.