Color Segmenter Edit ControlCognex VisionPro

The Color Segmenter tool provides a graphical user interface to the CogColorSegmenterTool, which you use to separate pixels from a color image into a grey scale image of light and dark pixels, where light pixels represent color pixels that fall within a desirable range of color and dark pixels represent color pixels that fall outside any desirable range of color. The grey scale image that a Color Segmenter tool generates represents just the portion(s) of the input image having color values that you want to analyze further. The following figure shows the Color Segmenter tool edit control:

Cognex Color Segmenter Color Segmenter Color Segmenter Whole Control

The edit control allows you to perform the following actions:

  • Build a collection of color ranges, using a color space of either Red, Green, Blue (RGB) or Hue, Saturation, Intensity (HSI).
  • Increase or decrease the allowed values for each color range.
  • Establish a range of color values which the Color Segmenter tool will represent with varying shades of grey in 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 CogColorSegmenterTool to a QuickBuild Job, it appears with an input terminal for the incoming color image and an output terminal for the outgoing grey scale image it generates, as shown in the following figure:

Cognex Color Segmenter Color Segmenter New Color Segmenter

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

Control Buttons

Cognex Color Segmenter Color Segmenter Color Segmenter Control Button Bar

The following table describes the function of each button:

Table 1. Control buttons
ButtonDescriptionFunction
Run Button
RunGenerate the segmented image based on the current collection of color ranges.

Local Display Button

Local image display

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

  • The Current.InputImage buffer contains the next image the tool will segment plus a graphic for the current region of interest.
  • The LastRun.InputImage buffer displays the last image with an overlay color representing those pixels the tool considers to be within the desired collection of color ranges.
  • The LastRun.SegmentImage buffer displays the segmented image, where light pixels represent pixels from the original color image that fall within the collection of color ranges, and dark pixels represent pixels from the original color image that fall outside the collection of color ranges.
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 Segmenter tool to a VisionPro persistence (.vpp) file. The edit control allows you to choose between saving the Color Segmenter 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 generate the collection of color ranges that the Color Segmenter tool will use to generate a segmented image. The following figure shows the Colors tab with a single defined color range:

Cognex Color Segmenter Color Segmenter Color Segmenter Colors Tab

Collection Table

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

Cognex Color Segmenter Color Segmenter Colors Tab Function Buttons

The following table describes what each button does:

Table 2. Collection Table Buttons
ButtonDescription

Cognex Color Segmenter Color Segmenter Add Point Function

Add a new color range using either a specific point or by selecting a region of the Current.InputImage.

If you use a point to specify the new color range, the Colors tab displays a point graphic over the Current.InputImage, as shown in the following figure:

Cognex Color Segmenter Color Segmenter Using Point Function

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:

Cognex Color Segmenter Color Segmenter Using Region Function

In either case, select a point or region to add to your color collection and click Accept. The following figure shows a Colors tab with a single color range:

Cognex Color Segmenter Color Segmenter Single Color Range

Cognex Color Segmenter Color Segmenter Delete Point Function
Remove the selected color from the reference table.
Cognex Color Segmenter Color Segmenter Move Up Function
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 Segmenter tool.
Cognex Color Segmenter Color Segmenter Move Down Function
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 Segmenter tool.
Currently Selected Color

The Colors tab also includes an area for modifying the colors in the collection:

Cognex Color Segmenter Color Segmenter Colors Tab Selected Color

The following table describes these controls:

Table 3. Currently Selected Color
ControlDescription
NameA name for the reference color that you can assign and change.

ColorSpace

The color space for the current image.

The tab displays the current values for Plane0, Plane1, and Plane2 for images in the RGB color space, or the values for Plane0, Plane1 and Plane2 in the HSI color space.

Range Tab

Use the Range tab to modify the current range along any one plane in the color space the image the currently uses. The Color Segmenter starts with a default range for each color plane, but you can use the graphics in the Range tab to increase or decrease the color values the tool will consider to be within the allowable range. The following figure shows a Range tab corresponding to a particular image:

Cognex Color Segmenter Color Segmenter Color Segmenter Range Tab

Any particular color range can be defined by the following parameters:

  • The nominal value indicates the average color value in the particular color space (RGB or HSI) defined for the image.
  • The low and high tolerance for any plane in the color space indicates the lower and upper values, respectively, that a pixel value can have in that color plane and be considered within the desired range.
  • The low and high tolerance softness values indicate pixels in the color plane for which the tool will apply a weighted value in the segmented image, ultimately giving the output pixel a grey value higher than 0 but less than 255.

    These weighted pixels represent pixel values at either end of the desirable color range, and can be analyzed by another vision tool, such as a Blob tool, to collect such information as the area and center of mass of particular objects in the original color image.

Graphically, these parameters can be represented by the following figure:

Cognex Color Segmenter Color Segmenter Graphic Parameters

The Range tab represents these parameters over a histogram of the values in the current plane, as shown in the following figure:

Cognex Color Segmenter Color Segmenter Actual Range Graphic

Use the handles in the graphic to select a particular parameter and slide it closer or farther away from the nominal value. Increasing the distance between the low and high tolerance values increases the range of pixels the Color Segmenter tool will consider for the output image. Increasing the low and high tolerance softness settings increases the amount of pixels in the output image that will have a grey value between 0 and 255.

The Range tab provides precise control over these parameters with the following settings::

Cognex Color Segmenter Color Segmenter Settings With Region Graphic

Table 4. Range Tab
ControlDescription
NominalThe nominal value for the selected color range.
LowToleranceThe low end of the allowable range of values for this color plane = Nominal + LowTol
HighToleranceThe high end of the allowable range of values for this color plane = Nominal + HighTol
SoftnessThe softness value at either end of the current range. The tool enforces a uniform software range at the low end and high end of the tolerance values.

The Range tab also includes the following settings:

Table 5. Range Tab
ControlDescription

Plane

Select the particular color plane for which you want to specify an allowable range of pixel values.

The tab displays the current values for PlaneRange0, PlaneRange1, and PlaneRange2 for images in the RGB color space, or the values for PlaneRange0, PlaneRange1 and PlaneRange2 in the HSI color space.

NameThe name for this color range

Histogram Graph

Specify whether you want to view the histogram for the current plane using a linear or logarithmic graph.

Both options represent the same data, but the logarithmic plot expands the size of peaks that are small in a linear plot. This can be helpful for viewing histograms containing a small amount of data about the amount of color along any one plane in the image.

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 Segmenter Color Segmenter Color Segmenter Region

Use the following controls to determine the region of interest:

Table 6. The Color Segmenter 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 Segmenter 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.
Graphics Tab

Use the Graphics tab to specify the type of graphics the tool should use to indicate various results in the LastRun.InputImage and LastRun.SegmentImage image buffers. The following figure shows the Graphics tab:

Cognex Color Segmenter Color Segmenter Color Segmenter Graphics Tab

Use the following settings to enable or disable particular graphics:

Table 7. Results
OptionDescription

OverlayColor

Enable an overlay color in the LastRun.InputImage representing those pixels from the Current.InputImage that the tool considers to be within a desirable color range.

Click Overlay Color to choose a color other than the default green.

Show Segmented ImageGenerate the LastRun.SegmentImage which contains the grey scale image of light and dark pixels, where the light pixels represent those color pixels from the Current.InputImage that the tool considers to be within a desirable color range.
Table 8. Diagnostic Options
OptionDescription
Show Input ImageDetermine 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.
Show RegionEnable a graphic representing the input region for the LastRun.InputImage.