# 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.