Extract Hair Silhouettes with GIMP Matting Engine

Extracting fine details like hair from a complex background is one of the most challenging editing tasks. This guide outlines the exact process for using the Foreground Select tool and its Matting Levin engine in GIMP to isolate intricate hair strands and convert them into clean silhouette cutouts.

Step 1: Prepare the Image Layer

  1. Open your image in GIMP.
  2. Go to the Layers panel on the right.
  3. Right-click your image layer and select Add Alpha Channel (if grayed out, transparency is already supported).
  4. Duplicate the layer by clicking the Duplicate Layer icon to preserve a backup of the original photo.

Step 2: Activate the Foreground Select Tool

  1. Navigate to the top menu and select Tools > Selection Tools > Foreground Select.
  2. Alternatively, locate the tool grouped under the selection icons in the main Toolbox.

Step 3: Draw the Initial Rough Boundary

  1. Click and drag around the subject to draw a rough lasso contour.
  2. Ensure you leave a small margin of background around the hair to give the matting algorithm enough context.
  3. Close the loop by clicking on your starting point, then press Enter. A dark blue mask overlay will cover the unselected outer area.

Step 4: Configure the Matting Engine

  1. In the Tool Options panel (typically on the left), locate the Engine section.
  2. Ensure the engine dropdown is set to Matting Levin (which produces superior results for soft boundaries like hair compared to standard engines).
  3. Adjust the Stroke width to a size suitable for brushing over the hair details.

Step 5: Paint the Foreground Strands

  1. Ensure the brush mode is set to Draw foreground (indicated by a green icon or radio button).
  2. Paint directly over the solid areas of the subject and swipe through the hair strands where they overlap the background. You do not need to fill every pixel—simply draw strokes across the transitions.
  3. If necessary, switch to Draw background to brush over any background areas erroneously trapped near the hair.

Step 6: Compute and Preview the Mask

  1. Check the box labeled Preview mask in the Tool Options dialog.
  2. GIMP will process the Levin algorithm and render an alpha extraction preview.
  3. Inspect the flyaway hairs against the preview background. If fine strands are missing, uncheck the preview, brush over those areas with the foreground stroke, and check Preview mask again.

Step 7: Create the Active Selection

  1. Once the preview accurately captures the hair details, click the Select button in the floating dialog box or press Enter.
  2. The mask will convert into an active selection boundary (marching ants) around your subject and hair details.

Step 8: Generate the Silhouette

  1. Create a new transparent layer by clicking Layer > New Layer and label it "Silhouette".
  2. Set your Foreground color to black (or your chosen silhouette color).
  3. With the selection still active, click Edit > Fill with FG Color.
  4. Deselect the active area by pressing Shift + Ctrl + A (or Shift + Command + A on macOS).
  5. Hide the original photo layer in the Layers panel to reveal the isolated hair silhouette.