Mask
The Mask function 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.
Next, the image is segmented based upon edge transitions, using blob 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.
- If the part the mask is covering will exhibit motion from image to image, ensure that the mask has a 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.
Mask Inputs
Parameter | Description | ||||||||||||||||||||||||
Image |
This argument must reference a spreadsheet cell that contains a valid Image data structure. By default, the cell referenced is $A$0, which contains the image data structure returned by AcquireImage. |
||||||||||||||||||||||||
Fixture |
Defines the region of interest or ROI relative to a Fixture input or the output of a Vision Tools function's image coordinate system. Setting the ROI relative to a fixture ensures that if the fixture is rotated or translated, the ROI will be rotated or translated in relation to the fixture. The default setting is (0,0,0), the top leftmost corner of the image.
|
||||||||||||||||||||||||
Region |
Also known as the region of interest or ROI, specifies the region of the image that undergoes image processing; creates a region that can be transformed and rotated. With this parameter selected, clicking the Maximize Region button will automatically stretch the region to cover the entire image. Note: 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.
|
||||||||||||||||||||||||
Note: The Fixture and Region parameters must be defined within the bounds of the image; otherwise, the function will return #ERR.
|
|||||||||||||||||||||||||
Scale |
Specifies the size (80 to 120; default = 100)of the mask, relative to the trained fixture size, as a percentage. Note: To view the effect of changing the Scale parameter, drag-and-drop the control to the spreadsheet. This will create an EditInt that is automatically classified as an absolute reference to the Scale parameter. Modifying the value of the Scale parameter while in the function's property sheet will automatically re-train the mask at the new scale value, which obscures the effect of the parameter change.
|
||||||||||||||||||||||||
External Region |
Specifies a spreadsheet Cell References that contains aControls Functions. When this parameter is used, the Mask function will ignore the Region and Fixture settings and inspects the image area specified by the referenced region. Note: If this parameter has been set as a reference to an external region, to use the function's internal region, this parameter must be manually set to zero by entering the value 0 in place of the cell reference. Otherwise, the function will continue to reference the external region.
|
||||||||||||||||||||||||
Segmentation |
Specifies how the function will perform the segmentation analysis.
|
||||||||||||||||||||||||
Mask Generation |
Specifies how the function will construct the mask.
|
||||||||||||||||||||||||
Timeout |
Specifies the amount of time, in milliseconds (0 to 30000; default = 0), that the function will attempt to calculate the mask before execution is halted and #ERR is returned. 0 = no timeout |
||||||||||||||||||||||||
Display Image |
Specifies the type of output image the function will generate.
|
||||||||||||||||||||||||
Show |
Specifies which graphical overlays are displayed on top of the image.
|
Mask Outputs
Returns |
Returns a Mask data structure that contains an image mask based on either edge or segment data, or #ERR if any of the input parameters are invalid. Note:
|