CompareImage

Compares a region of interest with a template image and returns an Image with white pixels where the region does not match the template within a certain tolerance.

CompareImage Overview

CompareImage is designed to extract a template from the current image when the ForceTrain checkbox in the property sheet is selected. After you deselect the checkbox, CompareImage can map the pixels from the template to the input image for comparison and for producing the greyscale output image. Pixels that do not match the template image within a certain tolerance are displayed as bright or white pixels.

CompareImage Example

In this example, the goal is to use CompareImage to compare the template image of a "good" gasket with input images of gaskets on a production line.

  1. After inserting CompareImage into the spreadsheet, define the ROI by double-clicking on the word "Region" in the property sheet, which disappears to reveal the red ROI box overlaid on the image. Move or resize the box using the cursor, and click the OK button on the Job Edit toolbar (or presses the Enter key) to confirm the selection and return to the property sheet.

  2. Fixture the tool to another data structure. In fixturing, identifiy a distinctive feature that appears on all instances of the object and designate it as a reference point for subsequent vision tools. This allows precise comparisons or inspections to be made, even if the object is slightly rotated or shifted on the production line.

  3. To fixture the function, click the word "Fixture" in the property sheet and click either the Absolute Reference or Relative Reference button on the toolbar of the property sheet.

  4. The property sheet disappears, revealing the In-Sight spreadsheet. Move the cursor to select the Row, Column, and Angle cells from another data structure in the spreadsheet (for example, FindPatterns) as the reference for the fixture. Click the OK button on the Job Edit toolbar (or presses the Enter key) to confirm the selection and return to the property sheet.

  5. Ensure that the ForceTrain checkbox in the property sheet is selected, so that a template image (below) can be extracted automatically when an image acquisition is manually triggered. (However, simply selecting the ForceTrain checkbox triggers the image acquisition, so if the current image is acceptable, you can skip setting up the image and manually triggering the acquisition.) Once a template is selected, deselect the checkbox to prevent overwriting the template.

  6. Accept the default settings of the other parameters and click OK in the property sheet to complete the configuration for this example and apply the function to the input image.

During run time, the tool compares the template image with the input image. A "bad" input image might consist of a gasket marred by white marks (below).

Differences between the two are displayed as bright pixels in the greyscale output image (below).

Another tool (for example, DetectBlobs; see below) can reference the output image to make a decision about whether the gasket passes or fails inspection.