Did you see...

Capturing Details with Refine Mask

Last week on TipSquirrel, I introduced the Masks Panel, and today we’re going to take a closer look at an old feature that is new again with CS5. A few versions ago, Adobe introduce the Refine Edge command, and in Photoshop CS5, the Refine Edge gains some incredible new capabilities, and also becomes integrated with the Masks Panel as “Refine Mask.” This feature allows us to improve the edges of our selections and masks, and (in my opinion) completely replaces the deprecated Extract filter.

In today’s tip, we’ll take a stab at extracting this screaming young lady, hair and all, from the blue background – using a layer mask and the Mask Edge / Refine Edge feature (image courtesy of stock.xchng):

RefineMask-01

In order to use the Refine Mask feature, we have to have a selection to begin with, and in order to make a reasonably good starting selection, I’ll use the technique described in my tip on Selecting with Color Range (if you’re not sure how to use this excellent selection tool, check the link). We start by choosing Select > Color Range…

RefineMask-02

Make sure the Fuzziness is set to about 10, and Localized Color Clusters is checked as shown. Now, with the eyedropper tool active, hold Shift and drag in the blue areas of the sky to add blue to the sampled colors. Note that you may have to drag repeatedly over several areas to add the entire background to the selection:

RefineMask-03

At this point, we have a pretty good looking basic selection. But, remember the rule: Black conceals, and white reveals – in this case, our selection would reveal the sky while hiding the girl. The solution is to check the Invert option in the dialog box to reverse the colors:

RefineMask-04

Now our mask looks good, and we can click on OK to exit the Color Range tool and leave us with the selection: Now, recall that when we have a selection active, we can add a layer mask and the selection will automatically define the mask. Click on the Add Layer Mask Icon (ensure that your layer is not the Background layer, as you cannot add a mask to a Background layer):

More:  3D in Photoshop CS6 - Materials Properties

RefineMask-06

This leaves us with the apparent extraction, and we can see immediately that our selection is not perfect. Note the blue background that is still present, and the hair is not well defined at all. This is where we can call on Refine Mask / Mask Edge to help out:

RefineMask-07

Display the Masks panel (Window > Masks) and notice the option for Mask Edge… – this is what we want, go ahead and click it:

RefineMask-08

This will bring up a dialog box that looks a lot like Refine Edge from earlier versions of Photoshop – but with a few new (and, as we’ll see, very important) options. We’ll start with one of the legacy options in the Adjust Edge section, the option for Smooth – we’ll give this a value of 25, which has a favorable effect on the edges of the coat and head. If we bump up Smooth too far, we’ll start losing hair detail, so it becomes a bit of a tradeoff:

RefineMask-09

At this point, we can skip the remaining options in that section, and move up to the new Edge Detection section. We’ll move the value for Radius up to a higher amount, and watch the edge detection go to work. I found that a value of 80 did quite a bit to improve the hair, but at the same time we started getting some transparency in the coat area as indicated. We’ll fix that next:

RefineMask-10

Before we fix this, let’s take a look at what this radius is doing. If you’ve ever used Photoshop’s older Extract filter, you’ll recognize this radius as the width of the green paint that you used to highlight the areas where you wanted the extract filter to find edges. This is the same, and we can see the effect by enabling the option Show Radius. Notice how the areas of the coat have an equally large radius as the hair, and this is confusing the tool a bit – and we end up with partially transparent areas:

More:  Toggle Views in Photoshop CC

RefineMask-11

Now, if we click the option Smart Radius, the tool analyzes the area and will constrict the radius in areas where it can do so without impacting any edges. This will improve the areas of the coat quite a bit:

RefineMask-12

Now we can uncheck the Show Radius and go back to the prior view. Note that we may be able to see the results better on black, or against our original image, and the View option gives us quite a few choices for how to see the results. Here I’ve changed to a black background:

RefineMask-13

Now, let’s help our edge detection even further. Notice the small paintbrush icon next to the Edge Detection section. We can paint with the paintbrush to add areas for the tool to analyze, and we can Alt-paint (Opt-paint on a Mac) to remove areas from consideration. We can start by painting in the area of the hair to ensure we have the full hair covered:

RefineMask-14

Next, hold the Alt key (Option on the Mac) and paint over the areas near the edges of the coat to make sure they are excluded. Do not paint over the edge, but paint close to it to reduce the radius further. The mask results are already improving:

RefineMask-15

Once you’ve got it as good as possible, look to the Output section of the Refine Mask dialog, and ensure it is set to output to Layer Mask. This will ensure that all the changes are capture right in the original layer mask with which we started. Click OK to process the selection:

More:  Making Spotty Lettering With Photoshop's Layer Styles

RefineMask-16

RefineMask-17

Now, once the process is complete, you can see that the results are good, but still can be improved – click once again on Mask Edge… and re-enter the Refine Mask command. Use the paintbrush tool again, and paint again over the hairs to refine them further. This will have a nice effect and will improve the mask further – yes, Refine Mask can be repeated to get even better results!

RefineMask-18

Once you’ve painted in the optimum results, there is yet one more step before finishing. Click on the Decontaminate Colors option. Notice how any remaining blue color is removed. The side effect here is that when you use Decontaminate Colors, you can no longer output the the same layer mask – you have to output to a new layer with layer mask:

RefineMask-19

Once you click OK, you are ready to composite your image. A quick check of the image on various colored backgrounds shows that there is no blue contamination left in the hair:

RefineMask-20

RefineMask-21

And finally, a check of the mask itself (Alt Click or Option-Click on the layer mask to see it) shows the result of the Refine Mask tool:

RefineMask-22

Your layer is ready for compositing!

Today we’ve seen that the Refine Mask tool, an updated version of the Refine Edge command from previous versions of Photoshop, is quite capable of some amazing selection feats. You can use the command repeatedly to work on your masks, fine-tuning them iteratively as you go. Remember, too, the better mask that you originally start with (we used the excellent Color Range tool in this example) the better your mask will be.

 


 

See a video explanation of Refine Mask by Gavin Hoey Here

About Michael Hoffman (224 Articles)
Mike has been a photographer, artist, educator, and technophile for most of his life. Early in his career, he created technical illustrations and photographs for electronic equipment manufacturers, and taught classes in computer aided drafting and 3D modeling software. When digital cameras became widely available in the late 1990s, the move was a natural one, and has led to a happy combination of technology, software, photography and art. Mike is an Adobe Certified Expert in Photoshop and Acrobat, and is well versed in Lightroom and Photoshop Elements, as well as Illustrator and InDesign. He has also contributed his time and efforts to the excellent work being done by Operation Photo Rescue, in restoring photographs damaged by natural disasters. As an active member of the National Association of Photoshop Professionals, he continues his quest for excellence in art, excellence in design, and excellence in education.

2 Comments on Capturing Details with Refine Mask

  1. Just got CS5 a bit ago and I’m anxious to try this out. Looks like quite the time saver and yields great results. Thanks!

  2. Nice tutorial. However, it will be quite a bit difficult with a more complex background than a plain blue sky.

Leave a comment

Your email address will not be published.


*