Using the Threshold Function to Extract Hairthe Task

The following example focuses on increasing existing contrast levels so you can achieve the most exact selection of fine structures possible. Though this solution is not perfect, it may serve as a brainteaser for developing your own solutions.

First you'll want to choose Colors > Threshold so that you can create a mask layer with high contrast. You can employ painting tools to touch up this layer and subsequently use it to create selections that will help you to edit the actual image.

fi "extractinghairjrf-27.0 [RGB. 2 layers) 1050*1400 - GIMP 1 = . B I jg

File Edit Select View Image Layer Colors lools Filters Video

Figure 4.16

The mask layer is being created; it will serve to extract the hair.

fi "extractinghairjrf-27.0 [RGB. 2 layers) 1050*1400 - GIMP 1 = . B I jg

File Edit Select View Image Layer Colors lools Filters Video

\J] Preview

\J] Preview

WORKI NG WI TH BLACK-AND-WH I TE AND COLOR I MAG ES

Figure 4.17

Touched-up hair strands on the mask with the Background layer visible from underneath

Figure 4.17

Touched-up hair strands on the mask with the Background layer visible from underneath

The prerequisite is that the selected image object should stand out to some extent from the rest of the image.

• Open the girl.png image in the SampleImages folder on the DVD.

• Save it as extractinghair.xcf in the layer-enabled XCF format.

• Select the Image > Mode menu item and make sure the image is in RGB mode; if it isn't, change the mode.

Duplicate the Background layer (in the Layers dialog). Name the new layer mask.

• Make sure the layer has an alpha channel (transparency attributes) by right-clicking in the Layers dialog and choosing Add Alpha Channel from the context menu, thus adding transparency to the layer.

• Use the Threshold function (Color > Threshold) to set the mask layer so that the hair strands are fully displayed— there should be an adequate amount of contrast between the hair and the background of the image. Be aware that a solitary hair is extremely difficult to capture, even with this wonderful tool.

• When the hair is defined by contrast, choose Select > By Color (or use the Select by Color tool) to create a selection on the white image areas on the mask layer. So that you can work as accurately as possible, the selection should be sharp edged, i.e., no feathering.

• Choose Edit > Clear to delete the white image areas. Check the result.

• Create a selection across the image areas surrounded by the hair contour. In this case, that would be the face.

• Choose the Edit > Fill with FG Color menu item to fill the selection on the mask layer with black.

• If you have done everything right, the contour of the head with hair should be selected. If not, delete the old selection and create a new one. Right-click on the mask layer in the Layers dialog to open the context menu of this layer. Select the Alpha to Selection option.

In the image window, click the bottom-left icon to activate the Toggle Quick Mask. You can also select it from within the Select menu. Before you proceed, make the mask layer invisible by clicking the layer's eye icon in the Layers dialog.

You are now ready to do some touchup work on the reddish mask. Select the Paintbrush tool with a thin, soft brush pointer (depending on the image and its resolution; in this case, use 5 to 9 pixels). Touch up the incomplete hair strands in the example image. You may have to paint or erase the reddish mask to correct the hair jutting out. Remember, black color paints a mask and white erases it.

4.3 ExTRACTING HAIR fROM THE BACKGROUND —A TRICKY TASK

• Switch back to selection mode.

• Duplicate the Background layer and name it something like hair-extracted.

• Add an alpha channel to the duplicated layer (right-click in the Layers dialog and choose Add Alpha Channel).

• Click the eye icon in the Layers dialog to make the Background layer invisible.

• Select a soft edge or feathering of approximately 7 pixels, and reduce the selection slightly. (Select > Feather and set to 7 pixels; Select > Shrink and set to 2 pixels. Remember that these values are contingent on the image and your intent.)

• Choose Select >Invert to invert the selection to select the surface around the head.

• Make the hair-extracted layer the active layer.

• Use the selection to delete the background from the hair-extracted layer (Edit > Clear).

So far, so good—you think? A background with a different color would be useful in order to check the result of your selection. The background will make the subject of your photograph stand out better.

• In the Layers dialog, create a new layer named background-colored.

• Use a color of your choice to fill the new layer.

• Use the tonality correction (Colors > Levels and adjust the mid-tones slider) to make the hair-extracted layer a little lighter. The hair should appear shinier, and more strands will become visible.

• Use a large, soft eraser with reduced opacity to touch up transitions on the hair-extracted layer, if necessary.

fi *e>ítract¡n9ha¡rj<cf-27.0 (RGB, 4 layers] 1050k1400 - GIMP ! Ü! File Edit Select Viewr ¡triage Layer Colors Tools Filters Video

fi *e>ítract¡n9ha¡rj<cf-27.0 (RGB, 4 layers] 1050k1400 - GIMP ! Ü! File Edit Select Viewr ¡triage Layer Colors Tools Filters Video

Figure 4.18

The finished image with layers

Figure 4.18

The finished image with layers

0 0

Post a comment