03 October 2013

A Non-Destructive, Adjustable Method for Cutting Out an Image

The Black and White of Masking

In a previous tutorial I described a
way to cut out irregular images using the Free Select tool. I used to
use that technique frequently, but it's very time consuming, causes a
lot of work for the left-mouse-button finger, and leaves a sharp edge
unless either you remember to feather the selection before deleting the
cutout area or you use the Blur or Smudge tool to soften the edge.
It's also destructive to the image and, if you make a mistake, it's
painful to fix it.

I have since switched over to using masks. Not only is a mask quicker and easier to use, it doesn't affect the original image, so recovering from mistakes is simple, and if you use a soft brush you automatically get blurred edges. You want blurred edges so that the cutout image blends smoothly into whatever it's in front of.

This tutorial describes how to create the following image using a mask to cut out the background.

Let me give you my two hoots' worth.

Pre-Work

Before you begin masking, if you're
cutting something out of a photo, you may want to make all
adjustments and enhancements first. When you have the image looking
the way you want, create a new layer with a copy of the adjusted
image.

Step 1 — Create a Contrasting
Background

I find that having a background of a
contrasting color helps me make sure that I'm painting my mask
correctly. Choose a Foreground color [1] that does not appear
in the image and that contrasts as much as possible. Since my image
is mostly shades of brown, I chose green. Create a new layer [2]
below your image layer, selecting Foreground color [3] in the
New Layer dialog.

Step 2 — Create a Mask

To create a mask on a layer,
right-click on the layer in the Layers dialog and choose Add Layer
Mask [4]. Select White (full opacity) [5] and click the
Add button.

We're going to use only white and black on this mask. (It's also possible to use shades of gray for semi-transparency.) Here's an analogy to help you remember the difference between white and black on a mask. Think of the white as a piece of paper. The layer's image is on the paper, so the parts of the image covered by white are visible on the piece of paper. Think of the black as a hole or cutout. The parts of the image covered by black have been removed, so you're seeing what's behind or below the paper.

Step 3 — Remove Large Areas First

Before I start fine-tuning a mask, I generally use the Free Select tool to select large areas that can be removed quickly. Make sure the mask is active. The image layer should be highlighted and the mask icon on the right should have a white border around it. Hit D to set the Foreground and background colors to black and white [6]. Choose the Free Select tool (F) [7] and draw around a large area of the image that you want to remove, then use CTRL+, to fill the selection with black. Repeat until you've removed all the easy stuff.

Step 4 — Paint With a Fuzzy Brush

Now choose the Paintbrush tool
(P) [8], a Hardness 050 round brush [9], and make the
brush Size fairly large [10] to start with. Zoom in on the
image so you can see what you're doing clearly. Paint over the
still-showing unwanted parts of the image, getting near to, but
perhaps not quite touching the parts of the image that you want to
keep. Don't worry if you make a mistake. It's trivial to fix.

Step 5 — Fine Tune the Image Edges

To paint right next to the parts of the
image you want to keep, you'll need a smaller brush. You want to
paint such that the semi-transparent edge of the brush just covers
the edge of the remaining image. If you go too far over, use X
to swap the foreground and background colors, then paint white over
the image. Swap the colors again to continue painting out the
background.

During this stage you'll probably be
adjusting the brush size often, especially if you have to paint
around or along hairs. Just take your time and pay close attention.
For really small brush sizes, you won't get much, if any, edge blur,
so you may have to touch up some edges with the Blur tool or
the Smudge tool. You can also use the Smudge tool to slide
black or white between or along hairs. You can even select an area
and use Filters > Blur > Gaussian Blur with a small
number to blur the edges.

TIP: UseCTRL+SHFT+J to resize the image to fit the image window.

Finishing Touches

Once you're finished with the mask, as
a final check, put a white background behind it to check for missed
spots. If you have a very light image, put a black background behind
it. Touch it up as necessary.

You can now add a background of your
choice, or hide all the layers except the masked one and save it to a
PNG file with a transparent background.

Here's what I did with my owl cutout.
(Special thanks to my husband for advice on the framing.)

Update 24 July 2014

Over time I've changed my masking method. These days I use the Free Select tool and draw around the edge of the part of the image that I want to cut out, essentially using the method described in GIMP 2.8 Tutorial: Which Tool Should I Use to Cut Out an Irregular Image?, working on the mask instead of the image itself. After I get the cutout basically how I want it, I use a small Gaussian Blur on the mask to make the edges of the image blend better into whichever background it eventually gets put on. Then I may finish touching up the mask with the Paintbrush or use the Smudge or Blur tools around hair and feathers until I get them to look right.