Dan Margulis Applied Color Theory

Masking Hair

Posted by: "Les De Moss"  
Mon Oct 23, 2006 10:35 am (PST)
Subject: Masking Hair

Over the years I have tried a variety of techniques using both Photoshop and 3rd party plug-ins for masking hair out of a white background. I currently have about 60 studio images to mask and am looking for group input on accurate and efficient techniques some of you may have developed or tried.

I have used a variety of techniques over the years, but have found none that are both accurate and time-efficient. The final masked images will be placed on a variety of different color/density backgrounds.

I have posted a sample image at: www.digi-graphics.com/ctheory.htm.

If this is off-topic, please respond off-list to me at: com

Thanks in advance for any suggestions.

Les De Moss
DigiGraphics LLC
___________________________________________________________________________

Posted by: "Gene Palmiter"  
Mon Oct 23, 2006 4:07 pm (PST)
Re:Masking Hair

Google Russell Brown Advanced Masking...its a free video tutorial that is the best I have seen.
___________________________________________________________________________

Posted by: "Laurentiu Todie"  
Mon Oct 23, 2006 5:39 pm (PST)
Re: Masking Hair

Make as best a mask you can from the Yellow channel (Blue?) Paint the edges [not the highlights] with a light tint of the background (darken blending mode?) Keep the backgrounds as light as acceptable

Laurentiu Todie
___________________________________________________________________________

Posted by: "Stephen Marsh"  
Mon Oct 23, 2006 6:13 pm (PST)
Re:Masking Hair

Les, I have no time to look deeply now, but it appears that you could do yourself a major favour by experimenting with the use of the various matte commands after you have true transparency (no layer mask) - Remove white matte and or Defringe would be required.

This is above and beyond whatever "perfect" masking method you decide upon.

I have many ideas as this has been bread and butter work over the years for me, I will try to list some later (but perhaps Katrin Eismann covers all of them in her "making and extraction" book anyway!)

Best,

Stephen Marsh
___________________________________________________________________________

Posted by: "Howard Smith"  
Mon Oct 23, 2006 10:14 pm (PST)
Re:Masking Hair

Les, that's an interesting problem. It's doubtful that you're going to find any single method or plug-in that will make this kind of masking efficient if you're talking about doing it in several minutes and coming out with an outstanding selection. As for accuracy, wisps of hair do not require accuracy, only naturalness and realism. Here's a solution that enabled me to make a satisfactory (to me) selection in less than 10 minutes. The time required will depend on just how good you want the image to look and on what kind of background is going to be lying behind the hair. I moved my selected image over a previously posted image of the interior of an office area that had large, dark ductwork hanging from the ceiling. The white (or pale) fringes along the edge of the selected image were not excessive, but they were pretty obvious in front of the dark areas, less so in lighter areas of the image.

To make my selection, I made a copy of the Blue channel and used Curves to enhance its contrast, but not very much. Oddly enough, when working with delicate strands of hair, a strong mask is a hindrance and not a help. It worsens the white or light fringing. Of course the interior of the hair and the girl's face and shirt contained considerable detail that you don't want in this kind of mask. So I painted out the interior with black, avoiding the edges and the wisps of hair. No effort was made to be precise, just to get rid of the interior detail. Inverted the channel copy and made a selection from it. Used this selection to create a Layer Mask for the girl. Deleted the bulk of the white background by applying the mask. Changed the image resolution to match the image into which it was to be pasted. Draggged the selected image to the target image. Created a Layer Mask for the selected image layer. Changeed foreground color to black, brush blending mode to Darken with an opacity of about 25%. With the Layer Mask active, carefully painted over the edges of the hair where the white or light fringes were showing. If you overdo it, change the foreground color to white and the blending mode to Lighten and repaint the over-edited areas. With patience, perhaps some variations in brush opacity, brush size, etc., and care you will have an image where the delicate wisps and edges of the hair blend naturally into the background. I don't recall what Russell Brown did, but I seem to recall that both he and Katrin Eismann created a border selection around the perimeter of the hair and used Multiply mode to blend the edges of the hair into the background. It was a nice technique, but the result was not all that satisfying, not to mention the amount of time it takes to make a good selection of the edges. Those who don't like Layer Masks are invited to find another way to accomplish this. There must be other ways, and I for one would surely like to know what they may be.  Let us know what works for you. This kind of problem really stimulates the old thinking process, and posted solutions do the same.

Howard Smith
___________________________________________________________________________

Re: Masking Hair
Posted by: Stephen Marsh
Tue Oct 24, 2006 7:19 am (PST)

Les De Moss wrote:

I have posted a sample image at: www.digi-graphics.com/ctheory.htm.

If this is off-topic, please respond off-list to me...

Les, this is very much on-topic, I wish there was more posts that related to hands on work.

First, I would like to say that the overall workflow approach does not vary much - that is, isolating the subject and providing the best isolation on a transparent layer (the transparency can then also be saved as an alpha or layer mask channel).

Where the workflow can differ is how the transparent image is being used.

Les, are you compositing inside Photoshop using transparency/layer masks - or are you placing raster transparency into later versions of Adobe Illustrator or InDesign and using the transparency/flattening features outside of Photoshop?

The only real difference is that compositing/merging inside Photoshop offers more flexibility to retouch and blend hair into the background - above what is possible when placing images with raster transparency into Adobe illustration or layout software.

You have an "ideal" situation, pure white backgrounds! This makes your task fairly easy if this single image represents the other 60 for lighting and contrast between subject and background.

I think that I can recommend a method that will do the job in 2-3 minutes per photo and perhaps 5 minutes if doing some extra work. The hair extraction only takes seconds. You can put most of this into an action, which will reduce the time further.

My recommendation would be as follows (it sounds longer than it takes, honest!):

1) Turn the original flat background layer into a moveable layer.

2) Dupe this layer so that there are two copies of the image on the white background

3) Add a fill layer under the original images, say in 0r255g0b as a matte to evaluate the edits against (or change the preferences for layer transparency display).

4) Turn off the view for the upper white background layer

5) Target and work on the lower white background layer. Bring up the layer blending options. In the upper layer, drag the highlight slider from 255 to 254 or 250 or lesser to remove the white background - but not the fringe around the hair. Opt/alt click and split the upper highlight slider and set the range to 170/250 or whatever you like. Forget that the eyes, face, body start to drop out - the goal is to create a fast but accurate cut out of the hair by simply using blend if options.

6) Next target the upper white background layer. Add a layer mask. Invert the mask to black. Now paint in the areas that are missing from the lower blend if layer using white in the layer mask, but not too close to the edge of the hair. Obviously one can load in selections of masks made from the blue or L channel of LAB that have been refined with the threshold command to save on painting. These masks could have the hair detail removed, as fine hair detail is being added from the lower blend if layer. I find that using the pen tool is best for selecting the body, as it provides a nice clean outline that can be blurred/roughened a bit when saved as a selection into an alpha channel for use in masking.

7) Merge the two upper image layers together. Under the layer menu, select the matting command and experiment with defringe or remove white matte, or perhaps merged combinations of both matte commands using a duped layer.

There will be some tricky touch up work to remove some of the white background that is still left near the neck, but most of the job is done a lot faster and cleaner with blend if sliders instead of a layer mask. Background erase or other methods work well here. I am not too fussy in these areas nobody will ever see the original to compare.

That is the basic workflow, the lower layer uses blend if to isolate the hair. The upper layer adds in detail where the blend if fails. Merge both together and defringe/remove white matte. More time is actually spent on the body mask than the hair...the hair only takes 10-30 seconds with blend if sliders, but the touch up work is a little longer. I find this quicker than using layer masks for the hair but you may prefer them and the rest of these notes are easily adapted.

Have I mentioned before that I like blend if sliders and that they should perhaps be mastered before layer masks? I think this case study is a good example why.

The touch-up steps that one can take to go further, if one has more time include:

In Photoshop or other software, the image can be duplicated exactly in the same position over the background image/s or page layout elemetns. The lower image is set to multiply (overprint) blend mode. The upper image is in normal blend mode. The lower image can be masked to only apply the overprint blend where desired (often in hair or other fine detail). I think this was referred to earlier in regards to the tutorials from Russell and Katrin.

In Photoshop, one can add a new blank layer above the final extracted image. Next one uses the smudge tool at a very small pixel radius, mid to soft-hard edge brush and high opacity of say 80-95 set to sample all layers. This is where a pen/tablet really comes in handy for nice sweeping curves. One can "tease out" whisps of hair, fur and other detail by smudging out the edge pixels. Beyond a simple brush, there are many hair/fur custom brush shapes available or the advanced paint tool options. Once can also setup Bezier curves and stroke them with a paint tool to add in nice curling locks. One may wish to make these hair strands longer than necessary and then to erase/mask/fade them gradually shorter, trimming them. One can add motion blur to the smudged hair layer or other filtering (transparency protected noise) or edits. When you are done you can merge this layer down to make it part of the other merged layers - or you can keep all of your working layers if desired (for 60 images I would probably just merge working layers to a single transparent background layer, as I would always have the originals).

As others mentioned, one can touch up the halo/poor edges where white still shows by using a colour blend brush of an averge light hair colour. This may be best done in LAB mode, using the luminosity blending properties of impossible colours as mentioned by Dan in his books and magazine articles. I favour using the clone tool in colour mode as it provides natural variation, over the paint brush.

Perhaps a quicker way than painting/cloning in hair colour is to simply dupe the hair and blur/median it and to set it to darken blend mode at reduced opacity and to mask it off and paint it in over the white. The remove white matte and defringe commands make this step less of a concern when hair only has minimal white fringes.

There is one other option that is similar to blend if, but in a filter/plug. It is for classic Mac OS or Windows. Named Eliminate White, you can google this and many other similar free plugs that will turn all white or black pixels transparent (and similar shades to a lesser opacity). Often running the filter in a selction and then running the remove white/black matte layer command is required, depending on the background colour to restore lost density due to the filtering process. If anybody knows of a version that works with OS X I would like to know.

The highlight command of shadow/highlight can also help to bulk up fine hair that may be almost lost in the extraction process, multiply blend mode and blend if sliders and layer masks can also be good too.

One last tip, perhaps work at final resampled output size to save time. If quality is more important, then extract in high resolution and then resample down dupes (a lot of the fussy work will be lost, so if time is critical it often pays to work at final resolution so as not to waste time on things that are lost in resampling output).

I could supply the action Les, but I have to leave you something to do besides picking up the pay for this job! :) It is all in the steps listed above, let me know if you get lost.

These are the 'retouching secrets' that I used on a daily basis when working on magazines. I hope the guild does not come after me for sharing them!

Sincerely,

Stephen Marsh.
___________________________________________________________________________

Re: Masking Hair
Posted by: "Veli Izzet Cigirgan"
Tue Oct 24, 2006 8:00 am (PST)

Hi,

Just looking at the image, and depending on the background you would use, I would consider

1- Using blend-if sliders, to throw out anything that is white on the girl layer (of course you have to use another layer for the t-shirt, eyes and teeth).

2- Painting around the hai˘r in color mode, using the color of the background.

Hope this helps,
Veli Izzet
___________________________________________________________________________

Re: Masking Hair
Posted by:  Dan Margulis
Tue Oct 24, 2006 9:36 am (PST)

Stephen has pre-empted most of what I was putting together in response. Definitely if you have this many similar images it's worth writing an action. Like Stephen, I use Blend If to try to isolate the hair as much as possible so as to eliminate having to paint edges in.

For making this type of mask, I always take a copy into LAB to give better Blend If options. Hair (unless it's very black) is always positive in both the A and B channels, so it may be easier to isolate there than in any RGB channel.

I would also point out that it's often helpful to make a preliminary mask that isn't quite pure black, and then blur it at a high radius and fade to Lighten. Then, you can darken the darkest areas of what remains. Without that step, we often get white halos around the hair when we try to merge it onto a darker background. And if we try to make the mask more conservative without the blur, it's too easy to go overboard and clip off some strands.

Dan Margulis
___________________________________________________________________________

Re: Masking Hair
Posted by: "Paco Marquez"
Tue Oct 24, 2006 9:37 am (PST)

Les, I work with images like the one you posted regularly and am currently doing Twelve right now.

The best program for masking is KnockOut by Corel. They are often sold at eBay also.

The best way to go about this type of job is to first make a path around the subject. It is my experience that anyone with practice using paths can get the path done before someone is finished screwing around with the masks from channels method. Paths also work faster in a situation where you have a white shirt against white background like you do. When making the path around the head go inside the hair area not trying to mask the edges.

Before you do anything else, with the marquee too, select an area which includes all the hair, part of the chest and include some of the white around the hair. Command-j and now you'll have two layers.

Get rid of the figure's background using the path you made. I make a quick mask which is blurred to 2.8 and then hit the delete key six to ten times. this will eat at the edge in increments and make a nice gradation.

Then use KnockOut just on the head selection making sure you go as close to the edge of the hair as possible.

Then erase the bottom layer (the one you made the path for) where needed and merge visible.

All the best!

Paco
___________________________________________________________________________

Re: Masking Hair
Posted by: "Les De Moss"
Tue Oct 24, 2006 11:12 am (PST)

To all who have contributed to this thread so far.... thank you! I have set aside this afternoon to walk through several of your suggestions. I will contribute further to this discussion after I have experimented a bit and can report my findings and perhaps post a few images.

Since the images will be used in future, undetermined layout designs, my goal is to achieve transparent layers that can be placed above various density backgrounds without (or with minimal) needing customize the image layers for different color/density backgrounds. In the past, I have allowed the shortcomings of the masking (light halo's, etc.) to determine, in part, how the layout that follows is designed, i.e: 'hiding' halos through the use of a carefully chosen background color and density. I want to untie my hands from this creative constraint as much as possible.The time and effort it takes to improve the technique used for masking is a very worthwhile investment.

Stephen, I am starting with your post. Thank you so much for the time and effort to share this with me and the group.

Regards,

Les De Moss
DigiGraphics LLC
___________________________________________________________________________

Re: Masking Hair
Posted by: "Les De Moss"
Tue Oct 24, 2006 3:23 pm (PST)

Dan, at the risk of sounding ignorant for the very first time (today).... I understand the concept; to control (darken) halo and maintain subtle strands of hair, but could use a step-by-step for creating and applying this preliminary mask . I assume you would create the mask in LAB using blend-if, that the high radius blur is in the single digits somewhere. I don't know what you mean by 'fade to Lighten'..... by changing layer opacity or something else?

I know you're on the road. I'll be stabbing away at this while you're gleefully on cruise control between hotels. If I answer my own questions before you post... I'll let you know.

Les De Moss
___________________________________________________________________________

Re: Masking Hair
Posted by: "Laurentiu Todie"
Tue Oct 24, 2006 3:26 pm (PST)

a good (relatively hard to make) mask
should look like this:
http://www.retouching.com/NewFiles/MiddleMask.jpg

Laurentiu Todie
___________________________________________________________________________

Re: Masking Hair
Posted by: "Les De Moss"
Tue Oct 24, 2006 3:28 pm (PST)

Stephen:

This images will be composited within photoshop for later output to Chromira photographic prints. Nothing will be done outside of PS.

Les
___________________________________________________________________________

Re: Masking Hair
Posted by: "Les De Moss"
Tue Oct 24, 2006 4:30 pm (PST)

Laurentiu-

Yes, it looks like a good mask.

Did you create this, and if so, would you care to share the technique? Was it performed in PS or another program? Was the original image shot against a white studio background? What might I apply from this to the project I am processing at this time?

Les De Moss
___________________________________________________________________________

Re: Masking Hair
Posted by: Dan Margulis
Wed Oct 25, 2006 8:20 am (PST)

Les writes,

Dan, at the risk of sounding ignorant for the very first time (today).... I
understand the concept; to control (darken) halo and maintain subtle strands of
hair, but could use a step-by-step for creating and applying this preliminary
mask . I assume you would create the mask in LAB using blend-if, that the high
radius blur is in the single digits somewhere. I don't know what you mean by
'fade to Lighten'..... by changing layer opacity or something else?

Everybody has suggested ways of isolating the hair, which is easy enough to do. The problem is then to convert it into a mask, which means making it black, usually by means of a curve. The problem is that the curve is likely to make the soft edges too harsh (this was referred to by Howard Smith). When this happens, if you apply the hair through the mask onto a darker background, disagreeable white edges will appear. Yet if you aren't aggressive in applying the curve you may lose some strands or not achieve complete blackness in the center of the hair.

Whenever you apply a command, almost any command, you can Edit: Fade>Lighten, or you can execute the command on a duplicate layer set to Lighten. Lighten mode prevents Photoshop from darkening anything, but otherwise allows the command to do what it ordinarily does.

If you just blur the mask, its edges will get softer, which is good, but dark areas will grow into the background, which is bad because it will aggravate the light areas referred to above. The solution is to fade (or use a layer) to Lighten mode, which prevents the blur from darkening anything. The edges get softer, lighter, due to the blur, but the blur isn't permitted to extend into the background because it would be darkening it.

I find it best to darken the isolated hair slightly, then the blur faded to Lighten, and then the final darkening to produce a completely black center of the hair with a soft edge.

Dan Margulis
___________________________________________________________________________

Re: Masking Hair
Posted by: "Laurentiu Todie"
Wed Oct 25, 2006 8:25 am (PST)

... from the Blue channel; it took about 30 minutes of painting, dodging and burning.

The main ingredient is patience, but painting skill helps

The original was shot on white background and when it isn't, I use not calculations, but, like an old dot etcher that I am, individual channels as negatives and positives in layers of a new, greyscale document.
All Photoshop.

Laurentiu Todie
___________________________________________________________________________

Re: Masking Hair
Posted by: "Cicero Rodrigues"  
Thu Oct 26, 2006 4:09 pm (PST)

2006/10/24, Paco Marquez wrote:

The best program for masking is KnockOut by Corel. They are often
sold at eBay also.

Yeah, it used to be. I've been using it for years and it does a great job with hair and transparency.

But there is a new kid on the block and for the first time Corel KO (previously released by Ultimatte) is going to face some serious competition. Check it out:

Fluid Mask from Vertus <http: //www.vertustech.com/>

Best regards
--
Cícero Rodrigues
Fotógrafo
Tel (21) 2557-5896
___________________________________________________________________________

Re: Masking Hair
Posted by: "Paco Marquez"  
Thu Oct 26, 2006 7:12 pm (PST)

Cícero,

Thanks for the suggestion. I checked it out and it looks good. Will give it a try.

¡Suerte!

Paco Marquez
661 McKinley
San Juan, PR 00907
787-721-8554 Studio
787-587-7384 Cel.
http://www.pacomarquez.com
___________________________________________________________________________