How to extract hair from background using GIMP

In this tutorial I will show you how to extract strands of hair from the background. Capturing the best out of the image subject requires patience and modest amount of time (about 30 minutes, more or less, I guess – depending how familiar you are with GIMP and how fast you do it).

Here is a picture of Eva Longoria, before and after. You can download the stock image HERE. Result varies on the time involve in editing and enhancing.

Step 1 : Open GIMP, then go to File>Open. Select a picture from your computer then click Open.
Step 2 : Right-click the ‘background layer'(named eva-longoria.jpg in this case)>Add Alpha Channel.

Step 3 : Duplicate the ‘eva-longoria.jpg’ layer which creates a new layer ‘eva-longoria.jpg copy’.

Step 4 : At this time, we would like to make a good contrast out of our image in preparation to layer masking that we will do. So, to do this, go to Color>Curves and have the most desired adjustment settings like the one below:

Step 5 : Colors>Desaturate>Luminousity, then hit Ok. This step will reveal the image in black and white, where layer masking works.

Step 6 : Pick the Brush Tool and make the face/skin color the same with that of the hair (which is white), and the background with black. Don’t paint the cloth. When done, go to Select>All, then Edit>Cut. Notice that the layer will disappear, but don’t worry because that was just being queued ready to be pasted. A floating layer will appear in place instead.

Step 7 : Switch back to the ‘eva-longoria.jpg’ layer, right-click then select Add Layer Mask. In the dialog box that appears, select White (Full Opacity)>Add.

Step 8 : Now click the mask icon (that small white rectangle), not the image icon. This is where we paste the image we’ve cut earlier.

Step 9 : As we’ve mentioned earlier, a ‘floating layer dialog’ will then appear in the layers palette. Click the anchor button located below the layers palette and the second image below will appear as a result.

Step 10: Observe that the image above has a transparent background so we need to change the background so that the extracted hair will stand out. So create a New Layer (Layer>New…),fill it with black using the Bucket Tool.

Note : White is a better background than black, although you can choose any background of your preference.

Step 11 : Clone Tool>Clone all the grayish areas around the hair and edit the imperfections. Take your time. If satisfied, Flatten Image, then Save it.

Here is the final result:

6 responses to “How to extract hair from background using GIMP

  1. It’s a lot easier with Photoshop, and with better results. Just a few clicks and you’re done. The main difference is that PS features the ‘Refine Edge’ which captures the smallest details of the subject image. Check my recent related tutorial..

  2. The background of the final result would have been better if the color is lighter so we can see the difference. Nice tuts anyway.

    • After inverting the desaturated image, make sure that the foreground color is white. Now, grab the brush tool (big and hard) and paint the hair and skin (white of course, because we’ve set the FG color with this color). Make sure the BG is black, paint it otherwise if there are grayish areas. Note: you are still working here with the copied layer (e.g., eva-longoria copy).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s