# Color

The Color tools are used to identify and match objects based on color data, such as examining objects that have the same shape but are composed of different colors or shades of colors. They internally generate a histogram projection of the color by calculating the Average Color present.

The Color tools include the MatchColor and TrainMatchColor functions, both providing 24-bit resolution.

Note:

- You must be connected to a color In-Sight vision system or emulator to enable these 2D Vision Tools.

- The MatchColor function must reference a TrainMatchColor data structure. Otherwise, the functions will return an error (marked with #ERR in the spreadsheet cell).

For color machine vision applications where speed is important and the examined colors are largely uniform, the MatchColor tool provides the necessary speed and accuracy. The tool determines the average color in the tool's Region of Interest (ROI) and compares this value against the stored list of previously trained Colors. During the training phase, using the TrainMatchColor function, a Library of Colors is created, which defines the average RGB and HSI values within a ROI. Then, during run-time operation, the MatchColor function determines the average RGB or HSI value present within its ROI that matches the trained Colors created and stored in the Library of the TrainMatchColor function. The Color with the highest score is ranked as the best match.

The MatchColor tool is the most effective when used on objects with a more or less uniform/solid color, and is ideal for the following use cases:

- Color verification: You can configure the MatchColor tool to quantify how closely the ROI selected in the current image corresponds to the Library of trained Colors. The goal is to ensure that difference between the Color in the ROI and the trained Colors is minor.
- Part or color matching: You can also configure the MatchColor tool to report the Color that is the best match to the current Color in the image. A match score is used to rank each trained Color, and the Color with the highest match score is determined to be the best match.

The Color Tools are typically used with the following workflow:

1. Examine the object and determine if its color data would be better analyzed by the MatchColor tool.
2. Insert a TrainMatchColor function into the spreadsheet and build a Library of trained colors.
3. Insert a MatchColor function into the spreadsheet to compare live images against the trained Library.