# Define Mask

The Edit Mask Toolbar allows you to define image masks for any of the deep learning tools. With masking, you can exclude parts of the image from training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network..

You can launch the Edit Mask toolbar with the following methods:

- Select View > Edit Mask in the main menu bar.

- Right-click in an image and select Edit Mask from the context menu.

- Use the Ctrl+M keyboard shortcut.

## Masking Overview

During training and processing, the Deep Learning tools work by sampling the image, with the Feature Size being the nominal span of the Sampling Region, in pixels. During sampling, a significant amount of context information, also known as the Context Region, from around the Sample Region is also considered.

1 | Feature Size
2 | Sampling Region
3 | Context Region

When a mask is applied to an image, the pixels within the Sampling Region that are masked are always discarded. The Masking Mode parameter determines how the mask is applied to the Context Region.

Consider the following masked image A two-dimensional array of pixels that has the same size as a view. The pixel values in the mask image determine whether or not the corresponding pixels in the view are used for training or run-time processing., with the hypothetical Sampling and Context Regions:

When the Masking Mode parameter is set to the default setting of Transparent, the tool only collects samples within the unmasked parts of the image. However, the tool still considers context information from masked areas, signified by the bright green areas within the Context Region.

When the Masking Mode parameter is set to Mask, the tool discards any masked pixels within the Context Region, signified by the bright red areas within the Context Region. This setting also focuses the tool to emphasize the center of the ROI The Region of Interest (ROI) defines the area of operation for the tool. The ROI preserves the positions, angles, stretch and skew of the original image. during sampling.

## Import Mask to Other View

You can import a previously created mask and apply it to an image or images in the View Browser. To import a mask to another view A view of an image is a region of pixels in an image. Tool processing is limited to the pixels within the view. You can manually specify a view, or you can use the results of an upstream tool to generate a view.:

1. Launch the Mask toolbar.

2. Choose the views where you want to import the mask with one of the following methods:

   - Select one or more images in the View Browser, then right-click on the selection and chose Import Mask from the context menu.

   - Click on the Actions for N Views button of the Display Filter, and choose Import Mask from the context menu.

3. Select a mask file in the Import Mask-Image dialog.

4. Click OK to confirm your choice in the Apply Mask pop-up window.