Optics-2022 : Tutorials : Applying a EZ Mask to a Layer
Applying a EZ Mask to a Layer
EZ Mask is an easy to use interactive image masking tool capable of isolating almost any object in an image--even if you are dealing with fine hair detail, smoke, or reflections.
To work this magic, EZ Mask iteratively estimates the transparency value for every pixel in the image, based on a small sample of foreground (what you want to isolate) and background pixels marked by simple strokes on the image. Results show that compared with previous approaches, our method is more efficient and requires minimal effort to extract high quality masks for foregrounds with significant semi-transparent regions.
Stroke Trimap Tutorial
EZ Mask creates masks by using a trimap--a pre-segmented image consisting of three regions of foreground (what you want to isolate), background and unknown. Partial opacity values are then computed only for pixels inside the unknown region. Two trimap methods can be used: Stroke and Filled. This tutorial will use the Stroke method.
Our trimaps can be relatively sparse consisting of individual foreground and background brush strokes. All pixels left unmarked will be treated as unknown. After processing, if any fine foreground details are missing from the mask, the Unknown brush can be used in these areas to help recover lost detail.
1 Select a filter and preset that changes the image in an obvious way.
2 Click the Add Mask icon in the Layers window and choose EZ Mask.
Note: Once EZ Mask is selected, the effect of the filter in the Viewer can no longer be seen until a mask is created.
A good stroke technique is to draw an inner outline around the object you are extracting using the Paint Foreground brush and an outer outline using the Paint Background brush.
3 Define the area to be cutout by drawing foreground lines with the left mouse button. You can quickly draw straight lines if you click with the left mouse button, press Shift and then click in a different location. If you keep Shift depressed while clicking, you will create interconnected straight lines.
The Paint Foreground brush is selected by default when you enter EZ Mask and that is why you can just start drawing with the left mouse button.
The strokes should be near the boundary of the foreground, but not right up against the edge. Strokes that are closer to the boundary will dominate the creation of the mask. Also, if the foreground has varying colors, the strokes should cover these colors.
Note: The general rule is don’t put different stroke types too close together unless you need to.
4 Define background areas by drawing with the right mouse button.
or
5 Alternatively, you could select the Paint Background brush and draw with the left mouse button.
If the background has varying colors, the strokes should cover these colors.
Warning: If you only provide a few sparse strokes, a Stroke trimap will take longer to process than a filled trimap.
6 Click the Generate Mask icon or press the Enter key.
Once EZ Mask is done processing, the mask will be shown in the mask thumbnail of the Layers window.
7 Press the M key to view the Mask in the Viewer.
In the Mask, white is foreground, black is background and any gray areas in between represent a level of transparency. If the mask is not acceptable after processing, add a few strokes near the region where the mask is not accurate.
Note: To quickly toggle off the display of your strokes, click on the layer’s image thumbnail. Click the mask thumbnail to re-display the strokes.
8 If you see gray areas in the foreground object that should be completely white, make additional foreground marks in those areas.
9 If you see gray areas in the background that should be completely black, make additional background marks.
When drawing a stroke trimap, certain foreground details may be missing after the mask is generated. Using the Paint Missing brush in these areas can sometimes help recover lost detail.
10 Press the M key again to view the full color image.
11 If any fine foreground details are missing from the mask, click on the Paint Missing brush and draw over them with the left mouse button as illustrated by the purple strokes in the dog’s hair.
The purple colored strokes represent the missing areas.
12 Click the Generate Mask icon or the Enter key again to see how any new foreground, background and unknown strokes affect the mask.
See EZ Mask for more information.
Filled Trimap Tutorial
EZ Mask creates masks by using a trimap--a pre-segmented image consisting of three regions of foreground (what you want to isolate), background and unknown. Partial opacity values are then computed only for pixels inside the unknown region. Two trimap methods can be used: Stroke and Filled. This tutorial will use the Filled method.
Foreground and background brush strokes are used to mark definite foreground and background pixels while the Unknown brush is used to mark unknown, or mixed regions. Using this method, the entire image is painted/filled with one of the three brushes.
1 Select a filter and preset that changes the image in an obvious way.
2 Click the Add Mask icon in the Layers window and choose EZ Mask.
Note: Once EZ Mask is selected, the effect of the filter in the Viewer can no longer be seen until a mask is created.
When drawing a filled trimap, the best method is to draw the unknown areas first. Unknown areas are typically areas where the foreground is transitioning to the background. In the image below, the hairy edges of the Alpaca would be considered unknown areas.
3 Define unknown areas by selecting the Paint Unknown brush and drawing around the edges of the foreground with the left mouse button. You can quickly draw straight lines if you click with the left mouse button, press Shift and then click in a different location. If you keep Shift depressed while clicking, you will create interconnected straight lines.
Include as little solid foreground areas as possible, but be sure to draw over all of the unknown regions. Ideally, the unknown region in the trimap should only cover transparent pixels whose actual values are not completely foreground or background. In other words, the unknown region in the trimap should be as thin as possible to achieve the best masking result.
4 Define the area to be cutout by selecting the Paint Foreground brush and the Fill tool.
Using the current brush, the Fill tool fills a region defined by a brush stroke or the edges of the screen.
5 Click inside the area defined by the blue, unknown brush.
The area inside of the blue, unknown boundary automatically fills in with the green foreground brush. Using the Fill tool is much easier than drawing the entire area by hand.
6 Define background areas by using the Paint Background brush and the Fill tool. Since the Fill tool is already enabled, you don’t need to select it again.
7 Click on the background outside of the area defined by the blue, unknown brush.
The background area automatically fills in with the red background brush.
8 Click the Generate Mask icon or press the Enter key.
Once EZ Mask is done processing, the mask will be shown in the mask thumbnail.
9 Press the M key to view the Mask in the Viewer.
In the Mask, white is foreground, black is background and any gray areas in between represent a level of transparency.
Note: To quickly toggle off the display of your strokes, click on the layer’s image thumbnail. Click the mask thumbnail to re-display the strokes.
10 If you see gray areas in the foreground object that should be completely white, make additional foreground marks in those areas.
11 If you see gray areas in the background that should be completely black, make additional background marks.
12 If there are areas that should be marked as unknown, make additional marks with the Paint Unknown brush.
13 Click the Generate Mask icon or Enter key again to see how any new foreground, background and unknown strokes affect the mask.
14 Press the M key again to view the full color image.
See EZ Mask for more information.