Difference Masking Unmasked
Dave Hadden ©2006 Sundance Media Group

HDV:What You NEED to Know

 

"I need to make a Chroma Key, but I don't have a green screen, and I already shot the footage - HOW AM I SUPPOSED TO DO THIS!?!?" Never fear, "difference" masking is here!!!

Difference masking is a unique technique of masking that allows editors to remove subjects from just about any background regardless of what it is. Sometimes it can be challenging, but overall, it's a powerful effect.

Before you begin working with your own footage/media, you can download the images and veg files from the tutorial project by clicking here. (156k)

Start with a static background that you can loop - this can either be a still frame grabbed from the footage (remember to use "Best" quality when saving your frame grab) or a small section of video that you loop over and over again. Now if you don't have a full background image; that may not be the end of the world. You may be able to piece together a few bits and pieces of background from different frame grabs to be able to make a single image. You don't need Photoshop or other graphic editor, Vegas has the power required to generate the background. To do this, you just layer as many tracks as you need and use the Bezier mask in your pan/crop feature to compile the image. Then save a screen grab from the preview window. You could then delete all those tracks and use the frame grab for the Background.

Our background image.

You need to be sure the camera doesn't move, and shoot the subject(s) for your footage, and then capture it onto your computer.

This is the image/footage we'll use for masking

There are a few other things that you also need to be aware of and watch out for, such as changes in exposure, lighting, object placement between shooting BG and Subjects, and the like. If you do all of these things the rest of it is fairly straightforward… more or less.

Now that Vegas is open and you've captured your footage, you will need to insert at least five tracks. The first track you insert (Track 1) will remain blank and simply act as a parent track for the rest of the tracks. The second track you insert (Track 2) will be a child to track 1, and will be where all the magic happens, but that's not quite yet. This track (Track 2) will hold your BG media. The next track that we'll insert (Track 3) will hold your "subject" media and become a child to Track 2. Track 4 is next; this track will also hold a copy of your "subject" media at the same positioning as in track 3, however track 4 will be a child to track 1 and a partner of track 2. Track 5 which is a child to no track and a partner to track 1, should contain your destination background media. See the image below for a visual reference.

 

This is how your tracks should be laid out and parented.


At this point, you will have a completely nonworking mask, but that's how it should be, so now it's time for some magic.

It's been said that, "The difference between a good quality video and Professional quality video is in the details." Well, it's no different in difference masking. It won't work, unless you've got the settings set right, so let's get to it. We'll need to set Track 2's compositing modes first, so click on the compositing button next to the level slider on track 2 (the track compositing mode) and select "Difference."


Now, right below that slider on the left hand side of the track there is the "Parent Compositing Mode" selector, this should be set to "Multiply Mask." 

 

What you should see now


 is an image of the BG footage RGB values(Track 2) subtracted from the 1st track of subject footage RGB Values (Track 3). The difference in RGB values from the BG media (Track 2) and the Subject media (Track 3) is very minor in this case, thus we have an image made up of pixels with a very low RGB values where the subjects were (Ex. 255, 255, 255 minus 235, 225, 245 would leave us with 020, 030, 010 as the color of the pixel now being used as a mask), and no difference where the BG was. This would then leave us with a black BG and extremely muted colors where the subjects are, and no transparency as of yet.

Now come the filters, this is what makes it all work - but there's a sneaky little trick that you very likely do not know. It's called the "Pre/Post" Toggle, and it's right in the header of each filters keyframe track name on the bottom left hand side of the filters window. I'll get to that in a second when we've dropped in our FX. Let me preface this FX part by saying that all these FX are going in at the track level, and are all on the second track. We're starting with the most important effect and also the one that should appear last in your FX line up. This one vital effect that you must use in order for the whole thing to work is the "Mask Generator" effect. This alone won't give you a good looking mask, but it will give you that elusive transparency we've been missing. The filter accomplishes this by looking at the difference between the images on track 2 and track 3 and takes the all black (000,000,000) and makes it transparent and takes the less than black (001,001,001 and above) and makes it semi transparent, this alone doesn't work so we have to add some other FX to make this viable.

Now in order to get a good looking mask we should use a variety of filters including a B&W filter, Levels Filter, Median Filter, and a Gaussian Blur filter, in that order (generally), and all preceding the ever important "Mask Generator" filter. Now comes that little "pre/post" arrow button we talked about - change all the FX on your BG media track from "pre" (default) to "post" by pointing the arrow to the right,and that's simply accomplished by clicking on it. You may never have seen these arrows before or you may have, they are only visible when you're working with Track FX in a composite. I'm afraid I can't give you cut and dried settings for all these filters because they are somewhat specific to your clip, but I'll certainly give you some pointers to get you headed in the right direction.

First the B&W filter - it's common to make the entire clip B&W, that's easy enough, and this action merely simplifies matters when working with the other filters.

 

 

Next we have the levels filter -And this is where it can become a little difficult.  "Gamma" should be set to 1.000 (default), the "Output End" should be set at 1.000 (default), and the "Output Start" should be set at 0.000 (default). The "Input Start" and "Input End" are the sliders that you have to fine-tune to find the right numbers for the image you've got. I've often found that a 0.030 input start & 0.120 input end will give me a good range to work from. This filter very simply augments the levels of colors and brightness within which a clip will be allowed to either operate (Input) or what levels it will be allowed to send (Output).


Now we adjust the "Median" filter, this filter is used to clean up the mask a bit. If you want more information on Median, look in the Vegas help files or click the "question mark" icon in the filter. Basically the Median filter blends adjacent pixel information to smooth out differences. It's also a good noise reduction tool for some types of noise.

 

Normally I set the Median filters "Horizontal" and "Vertical" ranges to approx 0.150 and the "Offset" to around 0.650 (you may want to apply several median filters and do lower numbers on each to clean up the mask as well).

You may have guessed the "Gaussian Blur" filter is next and is used to clean up the mask a bit more.

 

It can be set to preference (I usually use about 0.010). Lower values are generally better. If you go beyond .020, you'll notice the mask usually becomes too large and blurred.

Finally, the Mask Generator filter can just be at the end and left at its default settings; ("Type" = Luminance, Not "Inverted, "Low in" = 0.000, "High in" = 1.000, "Low Out" = 0.000, and "High Out" = 1.000)

If you've followed these steps and adjusted for your own media where necessary you should be seeing your subject  cleanly overlaid on you BG of choice.

You might notice some holes or bleed thru in parts of the mask, depending on the footage. The repair technique here is to then select the Track 3 media and cut a Bezier Mask in the media Pan/Crop tool around the problem areas of the image. This makes the image black against white and therefore tells the difference mask that there's a large difference instead of no difference and makes it no longer see through. Keyframe as necessary. Additionally, you may want/need to keyframe various parameters in the various filters depending on subject movement, exposure, lighting angle, or other attributes of the frame as necessary.

That is essentially all there is to successfully generating a mask.

Now with your new found knowledge, let the masking BEGIN!!!

Good Luck,

David

FrigidNDEditing

**Many thanks to Matt C at Sony Media Software for the inspiration for this technique and tutorial. You can find his original with footage here.

BOOKS from VASST

Instant Digital Audio

Instant ACID

 

 
    Search the VASST site for other project files, tutorials, reviews, and more!
 View other VASST training tools, FREE! Click the link below to be transported to the VASST resources pages.
VegFiles
Plugins
Scripts
Hardware

 

Tutorials
Themes
Forums/Groups
HDVPortal

 

Books/DVDs
Reviews
FreeStuff
VegasFAQ's