19

I use the Pen Tool for 90% of the situations where I need to cut someone or something from a photo but sometimes it gets tricky, especially when it comes to hair.

Let's take the following image for example:

enter image description here

  • Pen Tool - don't even think about it, it would take years to do an accurate cut so you usually do a more bulky cut.
  • Magic Wand & Quick Selection Tool - in some cases these can work, especially if you know your way around with Tolerance and Refine Edge
  • Blending modes are very useful in some situations also

When confronted with such an image I usually do use one of the tools from above + get something like 10 color samples from the hair, create a new brush that I adjust from photoshop's brush engine and start drawing hair.

From everything I've tried, redrawing hairs gave me the best results so far.

Q: Is there a better way to get an accurate selection when cutting hair? Or, how can I improve what I've got so far?

PS: Just wanted to add that a situation where the background behind the subject is in a single color like in the sample I offered is rare, therefore an answer based entirely on same color selection won't help that much.

2

4 Answers 4

25

Advanced hair extraction tutorial

First off, plugins and simpler methods are available. This is if you want to get higher quality results. It is largely the same as ACEkin's answer except going into details and with visuals.

I'll be using this photo from Photo by Ariana Prestes on Unsplash.com:

Original Photo

Note: I'm going to be doing the body in a separate layer so I'll be ignoring it for most of this tutorial until the final few steps

Select the Channel with the most contrast in the fine outer hairs. I think Green is the best option:

Green Channel

I'm going to duplicate that channel and rename it to Hair Mask. This will be what I work on until otherwise stated.

Important: If your hair is light on a dark background then you need to invert some of this as far as when to Dodge/Burn and when to use Black/White.

Now to start Apply Image. Multiply or Overlay are good options, sometimes you can even Apply Image twice. Here I applied the Hair Mask to itself with the overlay and lowered the opacity in the settings a bit to not lose the really fine hairs:

Apply Image Overlay

I actually did Apply Image Overlay a second pass with a lower Opacity pushing the contrast a bit more. This isn't undoing the first one, its doing it a second time:

Apply Image Overlay again

Then go into Curves (Ctrl/Cmd+M) and adjust the White and Black point sliders.

Curves Adjustment

Setup some Guides so I could periodically show original vs current at 100%. Here's the first look after just doing Apply Image, Apply Image, Curves:

Mask after Apply Image Apply Image Curve

Now you can like ACEkin said use Brush set to Overlay. I prefer starting with Dodge and Burn though. Burn set to Shadow and I used Exposure of 12 then went over the hairs as carefully as possible. The more careful and time you take the better the results will be. This was maybe 3 minutes, not long at all:

Burn Hair

Then at this point go ahead and switch to Brush, Black and fill in the inside. If you want you can first do Black set to Overlay and make another pass at the edges. Again, more time you take the better the results:

After filling it in

Alright, now use Dodge on the spaces between the hairs. Brush set to Overlay White is another option, again I prefer Dodge and Burn. I did Dodge Exposure 12 on Highlights.

Dodge the White

Then fill the rest with White.

After filling the White

And let's see where we're at in the 100% view:

Completed Mask

With your completed mask selected go back to RGB channel and then layers and apply the mask. I did the body with a separate layer as I mentioned earlier so now I've applied that as well.

Then just refine your mask using the Refine Edge command be sure to use Decontaminate Color

Refined Edges

Now the background I picked doesn't really match the lighting and picture, but that's alright. Its not about whether the picture looks real, just about the mask. Could almost always take more time, this is by no means perfect, but here it is which is pretty good for the point of teaching the technique:

Finished Image

And our 100% crop this time looking at the original vs the finished:

Hair Cropped on BG Image

I didn't really think about the crop area when choosing a background image to drop in. Since its hard to see that particular area, here's with absolutely no changes to my mask, just got rid of that background for a plain white background for the comparison instead:

Final comparison

Not bad for a Mask from a JPG.

1
  • This sure looks nice and it's an improvement from the way I used to do it. Thank you for the detailed explanation.
    – Alin
    Commented Mar 2, 2016 at 7:26
3

This is best done by selecting an area close to but not intruding the hairline touching the background. Then adding a mask and refining the mask is the best method for separating the hair from the background.

For the initial selection, you may consider choosing a high-contrast channel, duplicated it, and using the brush in the Overlay mode, paint the outside with white and inside with black. That will also give you a good starting point. You will still need to refine the mask but this second method may get you closer to the actual selection. For the critical parts you may need to manually paint the areas in the quick mask mode so that you can see the image while refining it.

Please realize that this is an extremely condensed explanation of a tedious process.

4
  • Your first phrase describes exactly what I added in the PS of my question. The sample that I offered is a very rare (and happy) occasion but you usually don't get images with a single color background. Also, while I agree with most of what you said, this still doesn't give a better result than making a rough selection and redrawing the loose hairs...
    – Alin
    Commented Mar 1, 2016 at 15:42
  • @Alin this will give you the best results even if the color differs. I can make a more thorough answer when I'm at home
    – Ryan
    Commented Mar 1, 2016 at 17:01
  • @Ryan Ok, there might be something I'm missing here, awaiting your answer when you get home. Thanks :)
    – Alin
    Commented Mar 1, 2016 at 17:15
  • 2
    @Alin, when you make the rough selection you want to make sure not to include any part of the background because the refining process relies on estimating what is in and what is out. Complex backgrounds will be challenging, but depending on the image one channel may provide "reasonable" separation from the object. You will probably never extract a person with a big hairdo in front of a yew bush even with the best of the plugins. You win some ...
    – user45605
    Commented Mar 1, 2016 at 19:07
2

You can start by selecting the background by color and tweaking it with a brush in Quick Mask, but in my experience I've never had very good results doing this by hand. Even if you carefully mask around each hair you still get a lot of bleed through of the old background. I usually just clip out the fuzzy hairs and that's usually good enough for small format, low-res stuff.

There are photoshop plug-ins that can do this for you quickly and easily. I'm not a professional retoucher, but I am a working Art Director and I've never been able to do as good a job as a these plug-ins for photoshop seem to be able to do, though I've never actually used on.

You also might consider the plug-in if the focus of your work will be on the hair. i.e. This will be in an ad for hair products or it's a full page ad that's zoomed in the hair and it would look sloppy if you just clipped out the details.

If don't mind spending money a plug-in will do it easily and better than you can by hand. Here's one plug-in I found doing a quick google search: https://www.topazlabs.com/remask

0
0

This is an old question, but I think an update with a more recent version of Photoshop would be helpful here.

Photoshop's Select and Mask functionality can be used to make very good masks of fine hair. The basics are as follows:

  1. Use the Quick Select tool to select the subject, or even the automated Select Subject functionality will work in many cases. Don't worry too much about the initial selection.

Something like this will suffice

enter image description here

  1. Click on the Select and Mask button, and the dialog will open

  2. Choose the Refine Edge brush at the left side, a make the brush a fairly large size, and paint over areas where there is fine hair.

enter image description here

  1. You can then continue tweaking the mask using the controls on the right, moving the shift edge slider, and decontaminate colours slider are probably the most useful here. The decontaminate colours function can help remove any light halo around the hairs, helping them to blend in better with a new background.

Here's an example showing the completed mask

enter image description here

And below, this is after applying the mask to the layer, and replacing the background with another image. The result is pretty good.

enter image description here

Using the decontaminate colours option can sometimes cause some loss of detail/blurring which can be easily fixed with a little cloning of the hair. Since the hair is already masked you don't have to worry about going over the edges with the clone tool.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.