Color Extractor Edit ControlCognex VisionPro

The Color Extractor edit control provides a graphical user interface to the CogColorExtractorTool tool, which you use to extract pixels from a color image in order to create a grey-scale image of light and dark pixels based on the reference colors you specify. The tool also generates a color image that can be used as a diagnostic tool to verify that you are extracting the pixels of a desired color, or set of colors. The following figure shows the Color Extractor tool edit control:

Cognex Color Extractor Color Extractor Color Extractor Whole Control

The edit control allows you to perform the following actions:

  • Build a collection of color definitions.
  • Define whether the color is added to, or extracted from, the output image.
  • Define the shape, size and location of the region the tool will use to examine the color contained in each acquired image.

If you add a Color Extractor tool to a QuickBuild Job, it appears with an input terminal for the incoming color image and output terminals for the grey-scale and color images it generates, as shown in the following figure:

Cognex Color Extractor Color Extractor New Color Extractor

See the topic Adding Edit Controls to Visual Studio for details on how to add a Color Extractor 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 Extractor edit control automatically.

Control Buttons

Cognex Color Extractor Color Extractor Color Extractor Control Button Bar

The following table describes the function of each button:

Table 1. Control buttons
ButtonDescriptionFunction
Run Button
RunGenerate the grey-scale and color images based on the reference colors currently defined.
Electric Button
Electric modeToggle electric mode, where the Color Extractor tool executes automatically when particular configuration parameters change. In electric mode, a lightning bolt appears next to every electric property.

Local Display Button

Local image display

Open or close the local image display window. A Color Extractor tool supports the following image buffers:

  • The Current.InputImage buffer contains the next image the tool will process plus a graphic for the current region of interest.
  • The LastRun.InputImage buffer displays the last image processed by the tool.
  • The LastRun.OverallGreyScaleImage buffer displays the grey-scale image, where light pixels represent pixels from the original color image that fall within a defined color range to be added to the output image.
  • The LastRun.OverallColorImage buffer displays all the color pixels from the LastRun.InputImage that fall within a defined color range to be added to the output image.

Depending on the run parameters and graphic parameters you choose, the tool can generate the last run records for a number of defined color groups:

  • The LastRun.GroupGreyscaleImage<N> buffer contains the grey-scale image for a specific color group.
  • The LastRun.GroupColorImage<N> buffer contains all the color pixels for a specific color group.
Floating Display Button
Floating image displayOpen one or more floating image windows, which support the same image buffers as the local image display window.
Open Button
OpenOpen 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 Button
SaveSave the current properties of the Color Extractor tool to a VisionPro persistence (.vpp) file. The edit control allows you to choose between saving the Color Extractor tool with or without its image buffers and tool results.
Save As Button
Save AsSave the current properties of the vision tool to a new VisionPro persistence (.vpp) file.

Reset Button

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.

Tool Tips Button
Show ToolTipsEnable or disable the display of tooltips for individual items in the edit control.
Help Button
HelpOpen this VisionPro online help file.
Colors Tab

Use the Colors tab to define the colors that the Color Extractor tool will use to generate its grey scale and color output images. The following figure shows a Colors tab with two defined colors:

Cognex Color Extractor Color Extractor Color Extractor Colors Tab

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

Cognex Color Extractor Color Extractor Colors Tab Function Buttons

The following table describes what each button does:

Table 2. Collection Table Buttons
ButtonDescription

Cognex Color Extractor Color Extractor Add Point Function

Add a new color by selecting a region of the Current.InputImage.

Use the region graphic to define the pixels you want to include in this color and click Accept. The following figure shows a Colors tab with two colors:

Cognex Color Extractor Color Extractor Two Colors

See the topic Color Extractor Walkthrough for an example of defining colors to a Color Extractor edit control.

Cognex Color Extractor Color Extractor Delete Point Function
Remove the selected color from the reference table.
Cognex Color Extractor Color Extractor Move Up Function
IndexOf the selected color up one position in the reference table.
Cognex Color Extractor Color Extractor Move Down Function
IndexOf the selected color down one position in the reference table.

The edit control also contains the following parameters for defining a color definition:

Table 3. Color Parameters
ParameterDescription
DilationUse a Dilation value between 1 and 10 to set the range of color pixels you want to include in this color definition. Higher values allow the tool to consider pixels with approximate RGB values to be included in the analysis, while lower values force the tool to consider only pixels closer to the exact range of RGB values this color defines.
SoftnessUse a Softness value when you want to generate a grey scale output image with grey values that indicate how closely a pixel in the input image matches the defined color. Increasing this value does not cause the tool to consider more pixels to be included in the definition, but allows the tool to indicate how removed any particular pixel is from the definition itself. A low value generates a grey scale output image where pixels that are close to the color definition receive a medium grey value, while a high value generates a grey scale output image where pixels that are close to the color definition receive bright grey values and pixels that are further from the definition receive dark grey values. The higher the value of Softness, the more individual grey levels will be present in the output image.
MinimumPixelCountUse this value to define the minimum amount of pixels in the input image that match the color definition for inclusion in the grey-scale and color output images. For example, if the minimum value you specify is 20, there must be at least 20 pixels in the input image that match the color definition before they are represented in the grey-scale and color output images.
MatteLineLimitLow and MatteLineLimitHighEnable and use the Matte Line values to allow the tool to extract pixel values that are darker (low) or brighter (high) than the hues defined by the color definition.
DilationEnable and use this value to allow the tool to include pixels that range from the defined color into pure white. This can be useful when the objects in your input images display specular highlights from one or more light sources.

Use the Train button in the Colors tab to train the tool with the current set of defined colors. If you choose to enable the AutoTrain feature on the Run Params tab, the tool can redefine the set of enabled colors based on the latest training parameters and the previously cached color definition image.

Groups Tab

Use the Groups tab to manage and organize the individual color groups you want to use in this Color Extractor tool. The following figure shows a sample Groups tab:

Cognex Color Extractor Color Extractor Color Extractor Groups Tab

The tab contains a button bar for adding, deleting and organizing the color groups. For each group, the tab provides the following options:

Table 4. Color Group Parameters
ParameterDescription
CombineColorsSequentiallyWhen enabled, the grey-scale and color output images are generated based on the order of the colors within each group. If not enabled, then the tool combines all the colors that are to be added to the output images first, combines all the colors that are subtracted from the output images next, and then combines these two separate groups to produce the resulting output images.
EnabledDetermines whether or not this color group should be considered part of the containing color model.
Region Tab

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 some applications might examine just a portion of each acquired image. For example, the following figure shows the Region tab configured to use a rectangular region of interest:

Cognex Color Extractor Color Extractor Color Extractor Region Tab

Use the following controls to determine the region of interest:

Table 5. The Color Extractor Region Tab
FeatureDescription

Region

Select the shape of the input region. Selecting "None=Use entire image" means that the tool uses the entire input image. A Color Extractor tool supports the following input region shapes:

The set of region-defining parameters that appear depend on the region shape you use.

SelectedSpaceNameThe coordinate space in which the region is interpreted. For more information, see Coordinate Space Names.
Select ModeAvailable 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.
FitToImageCenters the copy region within Current.InputImage.

RegionMode

Defines how the tool interprets the region you specify.

  • Masked Region specifies that only the pixels that lie within the region are analyzed.
  • Bounding Box specifies that pixels that lie within a pixel-aligned bounding box that encloses the region are processed.
Run Params Tab

Use the Run Params tab to determine what results a Color Extractor tool generates. The following figure shows the Run Params tab:

Cognex Color Extractor Color Extractor Color Extractor Run Params Tab

Table 6. Run Parameters
ParameterDescription
SoftnessThresholdThe Color Extractor produces a count for the number of pixels in each image that represent matched colors. By defining a Softness value on the Colors tab, you can generate a grey-scale output image with grey values to indicate how closely any particular pixel matches a defined color. By default, the tool only counts output pixels with a grey value of 255 as pixels that fell within a defined color, but you can lower this default value and have the tool count pixels with a color similar to a defined color as object pixels. For example, lowering this value to 200 would result in the tool counting any grey-scale pixel in the output image with a value above 200 as an object pixel.
AutoTrainWhen enabled, allows the tool to automatically train before each execution if any run-time parameters have been modified.
Overall ResultsGenerate an overall OverallPixelCountEnabled, a OverallGreyscaleImageEnabled and a OverallColorImageEnabled for all the enabled color groups and their contained colors.
Group ResultsGenerate an individual GroupPixelCountsEnabled, GroupGreyscaleImagesEnabled and GroupGreyscaleImagesEnabled for each enabled color group.
Graphics Tab

Use the Graphics tab to control what graphics and images the tool can display. Enabling more options can affect the time the tool requires to execute. The following figure shows a sample Graphics tab:

Cognex Color Extractor Color Extractor Color Extractor Graphics Tab

The tab contains a number of options:

Table 7. Graphics Options
ParameterDescription
InputsShow a graphic representing the run-time mask, if you supplied one. The graphic is shown on the Current.InputImage display.
ResultsEnable the image options you want the edit control to display.

Diagnostics

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 of interest.

Check Show Diagnostic Input Image Mask to show a graphic representing the run-time mask, if you supplied one. The graphic is shown on the LastRun.InputImage display.

Results Tab

Use the Results tab to view the overall PixelCount and group pixel counts for individual color groups. The following figure shows a Results tab:

Cognex Color Extractor Color Extractor Color Extractor Results Tab