Mask

The Mask function Functions are tools that are available in Spreadsheet for processing and analyzing acquisitions or other results. You can add functions to your Spreadsheet job to create tool chains and produce results for specific applications. is used to create an irregularly shaped binary image mask, which is used to highlight certain areas of the image ("care pixels" which are assigned a value of 255), while also excluding other areas from being inspected ("don't care pixels" which are assigned a value of 0). This function can be used as an input with the SurfaceFlaw and the Flaw Detection functions.

Overview

The image mask is used to remove certain features from the inspection, while highlighting other areas. The mask is created through an internal two-step process. The first step involves edge detection and segmentation, during which the input image is smoothed based on the Smoothing Factor parameter setting. Using the smoothed image, an edge magnitude image is internally constructed.

Note: For color images, the edge magnitude image is computed based on all three color channels (R,G,B).

Next, the image is segmented based upon edge transitions, using blob A blob is a group of pixels on the image that form a distinct pattern, typically used to represent objects, features, or areas of interest in object detection and segmentation tasks. analysis. This is performed on the edge magnitude image, with dark blobs being extracted into segments, which are indexed and labeled. The Mask Generation parameters, Maximum Small Hole Fill Size, Median Kernel Size and Erode Mask Count, can be used to fill holes, smooth borders and / or remove narrow strips in the image mask, respectively. The Median Kernel Size parameter is particularly useful in helping to smooth edges and remove stripes.

The second step of the process involves selecting the edges or segments that will be used to generate the image mask. By default, edges are used (the Mask Method parameter is set to Edge Mask by default) to generate an image mask based on edge magnitude. With this image mask, only edge pixels are masked, and all other pixels are to be shown. This type of mask is helpful when attempting to exclude things like labels, text or logos.

Segments may also be used, by setting the Mask Method parameter to either Largest Segment or Selected Segments. The background is indexed as 0, and the next largest segment is 1, with the rest of the segments being sorted based on their size (they are color-coded and indexed in the image). This type of mask is helpful when attempting to block out the background, or other larger areas in the image.

When setting up the function, the Display Image parameter can be used to display the segments. The segments will be displayed with a numerical index and color-coded (black pixels are not a part of a segment, and white pixels are part of the largest segment).

Once the mask has been properly configured, it will be trained and retain the mask internally as a model. While the function's property sheet is open, if any parameter is changed, the mask will be retrained to the new parameter settings.

Note:
  • If the part the mask is covering will exhibit motion from image to image, ensure that the mask has a fixture A fixture is a coordinate location on the image that keeps the tool in the place determined by the fixture..
  • If any of the following parameters are placed in the spreadsheet as absolute references to allow for external control of the parameters and the parameters are changed, they will automatically cause the mask model to be retrained: Mask Method, Smoothing Factor, Minimum Edge Contrast, Minimum Segment Size, Maximum Small Hole Fill Size, Erode Mask Count, Invert, Median Kernel Size, and/or Segment(s).
  • If the Region parameter has been placed in the spreadsheet as an absolute reference to allow for external control of the parameter, and the parameter is changed, the Train Mask button should be pressed to retrain the mask model. If the Region parameter is modified while in the function's property sheet, the mask model will automatically be retrained.