Image Mask EditorCognex VisionPro

This topic contains the following sections.

The Image Mask Editor provides a means for adding a mask to the training image of a CNLSearch or PMAlign tool. See the topic Using Search Masks for more information on the use of masks. Other VisionPro tools use masks to block undesired sections of the training image, but only the CNLSearch and PMAlign tools offer access to the Image Mask Editor. The editor will only create mask images, it cannot edit the underlying training image.

To launch the Image Mask Editor, click

Cog Image Mask Ctl Image Mask IMEditor Button

on the row of control buttons at the top of the edit control for either the CNLSearch or PMAlign tool edit control. The button is only enabled when the tool has a training image. You cannot launch the Image Mask Editor outside of the CNLSearch and PMAlign edit controls.

A mask image uses semi-transparent red pixels to represent Don't Care pixels, which are pixels masked off from consideration, while the Care pixels of the underlying training image appear unchanged. If you are using the Image Mask Editor to create a mask for a PMAlign training image, you can also add Don't Care but Score pixels, which appear in semi-transparent yellow. See the description of the PMAlign tool for more information on Don't Care but Score pixels.

The mask appears in the editor superimposed over the training image. For example, the following figure shows the Image Mask Editor with a mask over the training image of a PMAlign tool:

Cog Image Mask Ctl Image Mask IMEWhole Thing

The Image Mask Editor supports a button bar along the top and a tool palette along the side, with a display window for showing the training image with its corresponding mask. The following three buttons appear along the bottom of the editor:

  • Click OK to add the current mask to the training image and close the Image Mask Editor.
  • Click Cancel to close the Image Mask Editor and discard any changes to the mask since the last Apply.
  • Click Apply to add the mask to the training image while keeping the Image Mask Editor open.

The Image Mask Editor uses the ImageFile tool to open and save a mask image, and uses the CopyRegion tool to perform cut, copy and paste operations. Therefore, the Image Mask Editor will not function if you choose to perform a custom installation and do not install both the ImageFile tool and the CopyRegion tool.

Mask Images

A mask consists of a combination of the following types of pixels:

  • Care pixels, which are clear, allow the vision tool that analyzes the underlying image to include the underlying pixel in its analysis.
  • Don't Care pixels, which appear in semi-transparent red, prevent the vision tool that analyzes the underlying image from including the underlying pixel in its analysis.
  • Don't Care But Score pixels, which appear in semi-transparent yellow, indicate which pixels in the training image are ignored for the purposes of creating a search pattern, but when found in the search image are scored as clutter features. Don't Care But Score pixels are only available to mask images of a PMAlign tool.

Most mask images have the same dimensions as the underlying image, but you can use a mask that has smaller dimensions. The Image Mask Editor allows you to precisely control the size and placement of the mask over the image.

You can use the tools of the Image Mask Editor to create a new mask, or import an existing bitmap or TIFF file and use it as a mask. Be aware, however, that the Image Mask Editor does not support color TIFF images. To use a TIFF image as a mask, it must be 8-bit grey scale.

Finally, if you import an image to use a mask for a PMAlign tool, and the image contains pixels with a grey value between 128 and 191, the Image Mask Editor displays them in bright red. Cognex reserves grey values 128 through 191 and the PMAlign tool will not allow you to train a search pattern with a mask that contains these illegal values.

The Display

The Display window of the Image Mask Editor shows both the current mask and the underlying training image. Right-click within the Display window to display the popup menu shown in the following figure:

Cog Image Mask Ctl Image Mask IMEDisplay Window

Control Buttons

The Image Mask Editor supports the following button bar along the top of the editor:

Cog Image Mask Ctl Image Mask IMETool Button Bar

The following table describes the function of each button:

Table 1. Control buttons
ButtonDescriptionFunction

Cog Image Mask Ctl Image Mask Open Image Mask

Open Image Mask

Import an existing bitmap or TIFF file and use it as a mask image.

The Image Mask Editor can be used to import masks for both the CNLSearch tool and PMAlign tool, but the tools differ in the way they interpret the grey values in the incoming mask image.

The CNLSearch tool interprets the grey values of the incoming mask in the following ways:

  • 0: Don't Care pixels
  • 1 to 255: Care pixels

The PMAlign tool interprets the grey values of the incoming mask in the following ways:

  • 0 to 63: Don't Care pixels
  • 64 to 127: Don't Care but Score pixels
  • 128 to 191: Reserved for Cognex use (appear as bright red pixels in the TrainImage buffer)
  • 192 to 255: Care pixels
Cog Image Mask Ctl Image Mask Save Image Mask
Save Image MaskSave the current mask as a bitmap or TIFF file. You might want to test the same mask file on several different tools or in multiple applications.
Save As Button
Save AsSave the current mask as a different bitmap or TIFF file.
Cog Image Mask Ctl Image Mask Cut
CutCut the currently selected area of the mask image. The Cut button is only available when you are using the Selection tool from the tool palette. The area of the mask that you cut becomes transparent.
Cog Image Mask Ctl Image Mask Copy
CopyCopy the currently selected area of the mask image. The Copy button is only available when you are using the Selection tool from the tool palette.
Cog Image Mask Ctl Image Mask Paste
PastePaste the cut or copied area to the mask image. The paste operation pastes the entire area you cut or copied, including any transparent portion of the region you selected. Click on the pasted area and drag it to the location where you want to paste it, then click outside of the selection to permanently place the pasted area.

Cog Image Mask Ctl Image Mask Undo The Last Action

Undo

Undo the last action. The editor supports one level of undo.

Note: A paste operation is not considered an "action" until you permanently place the pasted item by dragging it to the location where you want it, then clicking outside of the pasted item. If you have clicked on the Paste button but not yet placed the pasted item, clicking the Undo button will undo the most recently completed action.

Cog Image Mask Ctl Image Mask Redo The Last Action
RedoRedo the previous undo action. The editor supports only level of redo.
Cog Image Mask Ctl Image Mask Erase All
Erase AllErase all pixels in the mask image with pixels of the currently selected color in the tool palette.

Cog Image Mask Ctl Image Mask Change Mask Offset And Size

Change mask offset and size

Modify the mask image offset and size with the following dialog box:

Cog Image Mask Ctl Image Mask Mask Offsetand Size

The X and Y offsets measure the offset from the upper-left corner of the image. If you resize the image, the upper-left corner of the old mask image will be copied to the upper-left corner of the new mask image.

Click Fit To Image to match the dimensions of the mask image to the dimensions of the training image. The fitting operation takes place immediately without the need to click Apply.

Cog Image Mask Ctl Image Mask Show Shape Control

Shape Control

Modify the graphic of the current shape tool with the following dialog box:

Cog Image Mask Ctl Image Mask Shape Control

The Shape Control button is only available when you are using one of the following tools:

  • Selection tool
  • Fill Ellipse tool
  • Fill Affine Rectangle tool

For many applications, you can use the graphic for the particular tool to adjust its location and dimensions. Use this Shape Control dialog box to provide precise dimensions or exact placement.

Cog Image Mask Ctl Image Mask Pointer
PointerSwitch the cursor in the Display window to a pointer.
Cog Image Mask Ctl Image Mask Pan
PanUse the hand cursor in order to pan the image within the Display window.
Cog Image Mask Ctl Image Mask Zoom In
Zoom inUse this magnifying cursor to zoom in on the image within the Display window.
Cog Image Mask Ctl Image Mask Zoom Out
Zoom outUse this magnifying cursor to zoom out on the image within the Display window.
Cog Image Mask Ctl Image Mask Fit Image
Fit ImageFit the image within the size of the Display window.
Cog Image Mask Ctl Image Mask Zoom 100
Zoom 100%Displays the image at a magnification factor at 100%.
Cog Image Mask Ctl Image Mask Pixel Grid
Pixel gridSuperimpose a grid over the borders of all pixels in the image. You must zoom in on the image in order to see the pixel grid.
Cog Image Mask Ctl Image Mask Subpixel Grid
Subpixel gridSuperimpose a grid within the border of each pixel in the image. You must zoom in on the image in order to see the subpixel grid.
The Tool Palette

The Image Mask Editor supports the following tool palette bar along the left side of the editor:

Cog Image Mask Ctl Image Mask IMETool Palette

The tools work only with the pixels that form the mask image. You cannot edit the underlying training image with the tools in the Image Mask Editor.

The following table describes each tool:

Table 2. Tool Palette
ButtonToolUse

Cog Image Mask Ctl Image Mask Selection Tool

Selection tool

Use the Selection tool to specify a rectangular portion of the mask image for cutting or copying. When you click the Selection tool, a graphic appears in the editor as shown in the following figure:

Cog Image Mask Ctl Image Mask Selection Graphic

Click on the graphic to display sizing handles on each. Use the handles to reshape the graphic. Click and drag the graphic to move it.

Cog Image Mask Ctl Image Mask Fill Tool
Fill toolUse the Fill tool to fill in the shape defined by the Ellipse or Affine Rectangle tool with the current color. This tool is available only when you are using the Fill Ellipse or the Fill Rectangle tool.
Cog Image Mask Ctl Image Mask Line Tool
Line toolUse the Line tool to draw a free-form line one pixel wide, using the currently selected color.

Cog Image Mask Ctl Image Mask Brush Tool

Brush tool

Use the Brush tool to paint mask pixels in the currently selected color. When you select the Brush tool you can change the size of the brush with the following graphic:

Cog Image Mask Ctl Image Mask Brush Size Selection

Select the size of the brush you want to use.

Cog Image Mask Ctl Image Mask Ellipse Tool
Fill Ellipse toolUse the Fill Ellipse tool fill a circular shape with the currently selected color. You can adjust the graphic on the image or use the Shape Control button to provide exact dimensions and a precise location. Once you have placed the shape in the desired area and adjusted it to the desired size, click the Fill tool button.
Cog Image Mask Ctl Image Mask Affine Tool
Fill Affine Rectangle toolUse the Fill Affine Rectangle tool fill an affine rectangle shape with the currently selected color. You can adjust the graphic on the image or use the Shape Control button to provide exact dimensions and a precise location. Once you have placed the shape in the desired area and adjusted it to the desired size, click the Fill tool button.
Cog Image Mask Ctl Image Mask Color Select
Color Selection toolSelect the desired color you want to use to draw, paint, or fill in the mask image. The CNLSearch tool supports only clear (Care) and red (Don't Care) pixels. The PMAlign tool supports clear (Care), red (Don't Care), and yellow (Don't Care but Score) pixels.