This topic contains the following sections.
The Color Match tool provides a graphical user interface to the CogColorMatchTool, which you use to examine an area of color in an image and generate a set of match scores between the examined area and a table of reference colors. The Color Match tool can be used to determine which color is currently present within an area of a run-time image. The following figure shows the Color Match tool edit control:

For more information on how a Color Match tool works, see the topic Color Matching.
The edit control allows you to perform the following actions:
- Build a reference table of color values, using a color space of either Red, Green, Blue (RGB) or Hue, Saturation, Intensity (HSI).
- Define the shape, size and location of the region the tool will use to examine the color contained in a run-time image.
- Choose an algorithm the tool uses to generate the set of match scores, and assign different weight to the color planes of the defined color space.
- Determine how the results the tool generates will be sorted.
If you add a CogColorMatchTool to a QuickBuild Job, it appears with an input terminal for the InputImage and output terminals for the best match score, the name of the color that generated the best match score, and the current confidence score, as shown in the following figure:

See the topic Adding Edit Controls to Visual Studio for details on how to add a Color Match edit control to your Visual Studio.NET development environment if you are creating a vision application using the VisionPro application programming interface (API). The QuickBuild development environment supports the Color Match edit control automatically.

The following table describes the function of each button:
| Button | Description | Function |
![]() | Run | Calculate the average color value from the current region of interest and compare it against the table of reference colors, generating a score of how the color in the region compares against each known color. |
![]() | Electric mode | Toggle electric mode, where the Color Match tool executes automatically when particular configuration parameters change. In electric mode, a lightning bolt appears next to every electric property. |
![]() | Local image display | Open or close the local image display window. A Color Match tool supports the following image buffers:
|
![]() | Floating image display | Open one or more floating image windows, which support the same image buffers as the local image display window. |
![]() | Open | Open a VisionPro persistence (.vpp) file that contains a set of saved properties for this vision tool object type. VisionPro reports an error if you try to open a .vpp file for another object type. |
![]() | Save | Save the current properties of the Color Match tool to a VisionPro persistence (.vpp) file. The edit control allows you to choose between saving the Color Match tool with or without its image buffers and tool results. |
![]() | Save As | Save the current properties of the vision tool to a new VisionPro persistence (.vpp) file. |
![]() | Reset | Reset the vision tool to its default state. The tool gives you a choice between resetting to the default-constructed state, which is appropriate when you are using it in a Visual Studio.NET application, or its template-initialized state, which is appropriate for QuickBuild applications. |
![]() | Show ToolTips | Enable or disable the display of tooltips for individual items in the edit control. |
![]() | Help | Open this VisionPro online help file. |
Use the Colors tab to generate the table of reference colors the Color Match tool will compare against the region of interest in a run-time image. The following figure shows the Colors tab before any reference colors have been generated, as well as an image that can be used to generate them:

The Colors tab displays a grid of the ColorCollection currently defined for the Color Match tool. Use the function buttons shown in the following figure to add, delete and reorder the items in the reference table:

The following table describes what each button does:
| Button | Description |
![]() | Add a new reference color using either a specific point or by selecting a region of the Current.InputImage. If you use a point to specify the new reference color, the Colors tab displays a point graphic over the Current.InputImage, as shown in the following figure: ![]() On the other hand, if you use a region to specify the new reference color, the Colors tab displays a region graphic over the Current.InputImage as well as the ability to control the properties of the region, as shown in the following figure: ![]() When you use a region, the Color Match tool computes an average from the color pixels the region contains. In either case, select a point or region to add to your reference table and click Accept. The following figure shows a Colors tab with a list of reference colors: ![]() |
![]() | Remove the selected color from the reference table. |
![]() | IndexOf the selected color up one position in the reference table, although the order of the reference colors does not affect the operation of the Color Match tool. |
![]() | IndexOf the selected color down one position in the reference table, although the order of the reference colors does not affect the operation of the Color Match tool. |
The Colors tab includes an area for modifying the colors in the reference table:

You can modify a reference color at any time with the following controls:
| Control | Description |
| Name | A name for the reference color that you can assign and change |
| ColorSpace | The color space for the current reference color |
The values for the individual color planes in the defined color space. |
Use the Region tab to specify the type of region you want to use to examine the run-time image. By default, the region of interest is configured to encompass the entire input image, but most applications will likely examine a portion of each acquired image. For example, the following figure shows the Region tab configured to use a rectangular region of interest:

Use the following controls to determine the region of interest:
| Feature | Description |
Select the shape of the input region. Selecting "None=Use entire image" means that the tool uses the entire input image. A Color Match tool supports the following input region shapes:
The set of region-defining parameters that appear depend on the region shape you use. | |
Defines how the tool interprets the region you specify.
| |
| SelectedSpaceName | The coordinate space in which the copy region is interpreted. For more information, see Coordinate Space Names. |
| Select Mode | Available when Region Shape is CogRectangle or CogRectangleAffine. Selects the set of parameters that define the rectangle. If cogRectangleAffine is chosen, note that the angles of rotation and skew can be specified in degrees or radians, although the underlying tool keeps the measurements in radians. |
| FitToImage | Centers the copy region within Current.InputImage. |
Use the RunParams tab to choose a metric that controls how the Color Match weights the various color planes depending on the color space you are using. The following figure shows the RunParams tab:

Use the following controls to establish run parameters:
| Control | Description |
Select the correct scoring metric depending on the color space of your acquired images. The options are:
| |
| Distance Weights | Set a weight in the range of 0.0 to 1.0 for each of the Weight0, Weight1, Weight2 or Weight0, Weight0, Weight0 color planes in the color space of your acquired images. Increase the value of a particular plane can help the tool distinguish between colors that have a similar value in one particular plane. |
| SortResultSetByScores | By default, the Color Match tool sorts results by the scores between the region of interest and the table of reference colors, but you can switch this to Index in order to have the tool display results according to the order of the colors in the reference table. |
The Graphics tab allows you configure the diagnostic record and control whether the LastRun.InputImage shows the region of interest. The following figure shows the default Graphics tab:

For Show Input Image, determine whether or not the input image is recorded as part of the diagnostic record, and whether the image is copied to the record or saved in the record as a reference.
Check Show Region to enable a graphic on the LastRun.InputImage corresponding to the region on interest.
The Results tab displays the results from the last run of the tool. The following figure shows an example Results tab:

The edit control for the Color Match tool generates the following results:
| Result | Description |
| ResultOfBestMatch | The Name and ResultOfBestMatch of the color that produced the best match between the region of interest in the reference table. |
| ConfidenceScore | An indication of how much the best color match can be distinguished from other reference colors. |
| Color | The three planar values, in either the RGB or HSI color space, of the observed color generated from the region in the run-time image. |
















