PixelMap Edit ControlCognex VisionPro

The PixelMap tool edit control provides a graphic user interface to the CogPixelMapTool, which lets you map define pixel value mappings between an input image and an output image.

The following figure shows the PixelMap tool edit control:

Cognex Pixel Map Pixel Map Pixel Map Whole Control

The edit control offers the following features:

  • A row of control buttons at the top left provide access to the most common operations.
  • A set of tabs organized by function.
  • An image display window that you can use to view input images, output images, histograms, and a graphical representation of the mapping. .
Control Buttons

Cognex Pixel Map Pixel Map Pixel Map Control All Buttons

The following table describes the functions of the buttons at the top left of the control.

Table 1. Control buttons
ButtonDescription

Run Button

Run the PixelMap tool. You must have a trained pattern, an input image, and specified run parameters. The tool searches for the trained pattern in the input image. You may constrain the pattern search to a search region within the input image.

Electric Button

Toggles electric mode. When selected, the PixelMap tool runs automatically if certain parameters have changed. These parameters are indicated by electric bolt icons that appear when the tool is in electric mode.

Local Display Button

Opens the local tool display window, which can display the Current.InputImage, Current.TrainImage, or LastRun.InputImage buffer.

Floating Display Button

Opens one or more floating tool display windows. You can display the Current.InputImage, Current.TrainImage, or LastRun.InputImage buffer. Unlike the local tool display, you can resize or move the position of the floating tool display window.

Open Button

Loads a VisionPro persistence (.vpp) file, which contains a set of saved properties for this vision tool object type. Loading a persistence file for another object type throws an error and the load is unsuccessful.

Save Button

Saves the current properties of the underlying tool to a VisionPro persistence file. You have the option to save either the entire tool or the tool without its images or results.

Save As Button

Saves the current properties of the underlying tool to a new VisionPro persistence file.

Reset Button

Resets the underlying tool to a default state.

Tool Tips Button

Enables or disables the display of tooltips for individual items in this edit control.

Help Button

Access the VisionPro Software Documentation.
Settings Tab

You use the controls in the Settings tab to create, move, delete, and view the reference points that define this tool's pixel mapping function. By default, Auto Compute Reference Points is checked and the tool generates a mapping by itself. If you want to change the mapping, uncheck the checkbox.

If Auto Compute Reference Points is unchecked, you can click and drag any reference point graphic (a small cross) to move a reference point. The mapping function defined by the reference points is shown in blue while the mapping function, as modified by the output scale, offset, and inversion is shown in green. The control enforces the requirement that the mapping function be monotonically increasing (each successive reference point must have an X-value greater than or equal to the preceding point).

Cognex Pixel Map Pixel Map Settings Tab

Table 2. Settings Tab
ParameterDescription
AutoComputeEnabledDefault is true. When the "Auto Compute Reference Points" is checked, ComputeMapping() is called as the user modifies any parameter that affect the reference points. This is not done when "Auto Compute Reference Points" is not checked.
Advanced button Cognex Pixel Map Pixel Map Settings Tab Compute Map Params Expand ButtonOpens the advanced features (Compute Map Parameters). You can choose how the mapping is created and define the Output Range of the Output Parameters. Some of the advanced properties can be modified only if the Auto Compute Reference Points checkbox is unchecked.

Logarithmic Histogram

If checked, the histogram of input image pixel values is displayed using a logarithmic scale for the Y-axis. Using the logarithmic display prevents the presence of a small number of bins with large numbers of samples from obscuring bins with small numbers of samples, as shown below:

Cognex Pixel Map Pixel Map Logarithmic

OutputDepth Sets the pixel depth of the output image. You can specify an 8-bit greyscale image (Grey (8 Bit)) as well as a 16-bit greyscale image with 8, 10, 12, 14, or 16 bits of actual image data. The Output image depth must be less or equal to the input image depth.
UseDefaultNonVisiblePixelValue You can set the default value for pixels that are missing (in case of using a DS1100, for example). The default non-visible pixel value (output1) is the first point. Otherwise it is user specified.

OutputScale

Sets the linear scale factor to apply to the output of the mapping function.

Note: This property should be used at runtime for scaling, instead of Max Range Multiplier, because it multiplies all reference points.

OutputOffsetSets the offset value to apply to the output of the mapping function.
OutputInvertedIf checked, the output of the mapping function is inverted.
Predefined Maps

If the Auto Compute Reference Points is uncheked, you can use these controls to define multiple reference points with a single click.

Cognex Pixel Map Pixel Map Settings Tab Predefined Maps

Table 3. Settings Tab
ParameterDescription
ComputeMappingThe Compute button directly calls the ComputeMapping() function once whenever it is clicked.

ResetLinear

Creates a linear mapping function with the specified number of intermediate reference points.

The created mapping is not useful as-is; this button allows you to create multiple reference points with a single click, then manually position the points as desired.

ResetQuantized

Creates a quantized (stairstepped) mapping function with the specified number of steps.

The created mapping is not useful as-is; this button allows you to create multiple reference points with a single click, then manually position the points as desired.

Advanced button Cognex Pixel Map Pixel Map Settings Tab Compute Map Params Expand ButtonOpens the advanced features (Compute Map Parameters). Some of these properties can be modified only if the Auto Compute Reference Points checkbox is unchecked.
Compute Map Parameters

Display the Compute Map Parameters section with the Cognex Pixel Map Pixel Map Settings Tab Compute Map Params Expand Button button in the top right corner, left from the image display.

With the CogPixelMapComputeParams, you can fine-tune the reference points that are generated when ComputeMapping() is called (when the user clicks on the compute button or when the Auto Compute Reference Points is checked).

Cognex Pixel Map Pixel Map Settings Tab Auto Compute Off Expanded

Table 4. Compute Map Parameters Table
ParameterDescription

Algorithm

Specifies the algorithm used to compute the input range that will be mapped to the output range.

  • MinMax: Uses the minimum and maximum values in the histogram statistics of the input image to fill the output range.
  • Tails: Uses the low tail and high tail in the histogram statistics of the input image to fill the output range.
  • MeanStdDev: Uses the mean minus a multiple of the standard deviation and the mean plus a (possibly different) multiple of the standard deviation to fill the output range.
  • TypeRange: Use the minimum and maximum values of the range of the input type (e.g. 0 and 65536 for 16-bit input images) to fill the output range. Note that the "proper" mapping of, e.g., the full 16-bit range to the full 8-bit range is a shift by 8 bits (or, equivalently, a division by 256), which implies that the correct mapping is from 65536 to 256, rather than from 65535 to 255.
LowTailFractionThe Low tail fraction is in the range [0, 1]. Used only if the Algorithm is Tails. The LowTailFraction and the HighTailFraction when added must be less or equal to 1. As one property increases the other will decrease.
HighTailFraction The High tail fraction is in the range [0, 1]. Used only if the Algorithm is Tails. The LowTailFraction and the HighTailFraction when added must be less or equal to 1. As one property increases the other will decrease.

LowPadFraction

The fraction of the initially-computed input range added to the initially-computed value of first map value. This value is typically negative.

Cognex Pixel Map Pixel Map Low Pad Fraction

HighPadFraction

The fraction of the initially-computed input range added to the initially-computed value of second map value. This value is typically positive.

Cognex Pixel Map Pixel Map High Pad Fraction

OutputRange Specifies the output range used in the mapping.
MaxRangeMultiplier Used to convert input pixels to output pixels, where the maximum pixel value is clipped to the maximum value allowed by the image type. For example, if the output image is a 16-bit grey scale image, with an encoding of 10, the upper limit of the range cannot be greater than 1024. This setting is particularly useful when mapping from a CogImage16Range image to a CogImage16Grey image, which allows the full 16-bit range image to be used, instead of just a portion of the image.

Note: Only used when Auto Compute Reference Points is checked.

Output1Fraction Specifies the first output pixel value used in the mapping. Used only if OutputRange is SpecifiedRelative. Range value is [0-1].
Output2Fraction Specifies the second output pixel value used in the mapping. Used only if OutputRange is SpecifiedRelative. Range value is [0-1].
Reference Points Tab

The Reference Points tab provides a table control that lets you view and set the exact value of all reference points.

To add or delete a reference point, use the two buttons at the top of the table. To modify a reference point, click on the value to modify and enter the new value.

Note: The Relative input and output values allow you to specify the reference points as a fraction of the range of pixel values in the image (input and output). If the input or output image type changes, the absolute (pixel value) values are adjusted automatically to conform to the relative values that you supply.

Note: The control enforces the requirement that the mapping function be monotonically increasing (each successive reference point must have an X-value greater than or equal to the preceding point).

Cognex Pixel Map Pixel Map Reference Points Tab

Table 5. Train Region Features
FeatureDescription
SetReferencePointInput Specifes the input value for a reference point as the fraction (0.0 through 1.0) of the range of pixel values supported by the input image type.
SetReferencePointOutput Specifes the output value for a reference point as the fraction (0.0 through 1.0) of the range of pixel values supported by the output image type.
SetReferencePointInputAbsolute Specifes the input value for a reference point as a pixel value.
SetReferencePointOutputAbsolute Specifes the output value for a reference point as a pixel value.
Region Tab

Use this tab to limit the operation of the pixel map tool to a region of the input image. If you specify a value other than None - Use Entire Image, the output image will be sized to the pixel-aligned bounding rectangle of the region that you specify.

Cognex Pixel Map Pixel Map Region Tab

Table 6. Search Region Tab
FeatureDescription
RegionThe the search region. Selecting "None=Use entire image" means that the entire Current.InputImage becomes the search region. The set of region-defining parameters depends on the selected Region Shape.

OnlyUseRegionToComputeRefPoints

When checked (it is unchecked by default), reference points are computed using the contents of the region, and the mapping is applied to the whole image. The size of the output image is the same as the size of the input image. When unchecked, the reference points are computed using the content of the region, and the size of the output image is the same as the size of the region. If the Region is set to "None=Use entire image" this property is ignored.

Note: If Auto Compute Reference Points is unchecked on the Settings tab, this parameter is disabled.

SelectedSpaceNameThe coordinate space in which the search region is interpreted. For more information, see Coordinate Space Names.
Graphics Tab

The Graphics tab lets you configure the graphics and diagnostics displayed by the tool.

Cognex Pixel Map Pixel Map Graphics Tab

Table 7. Graphics Options
ParameterDescription

Inputs

Use these controls to specify what graphics are added to the Current.Graphic Image display:

Cognex Pixel Map Pixel Map Current Graphic Image

  • Show Histogram shows a histogram of input image pixel values.
  • Logarithmic Histogram shows the histogram using a logarithmic scale for the Y-axis (must also check Show Histogram).
  • Show Final Mapping Function shows the mapping function (in green), as modified by the Output Scale, Output Offset, and Output Inversion values that you specified.
  • Show Histogram Statistics shows the histogram and histogram stats. This graphic record is added to the CurrentRecord to show all histogram statistics. The histogram is independently computed from the histogram generated when ComputeMapping() is called. The histogram is computed with all requested statistics and helps the users understand their images so they can adjust the computed parameters properly. This record is available for all image types supported: CogImage8Grey, CogImage16Grey and CogImage16Range. The histogram for CogImage16Range and CogImage16Grey only contains grey-levels from minimum to maximum. The histogram for CogImage8Grey contains grey-levels for all 256 values.

    Image Processing General Walkthrough Pixel Mapping Histogram Stats

  • Show Raw Mapping Function shows the mapping function (in blue), as defined by the reference points alone.
  • Show Reference Points shows a blue point graphic for each reference point.
  • Show Coordinate Axes shows coordinate axes graphics for the histogram.

Diagnostics

The Show Input Image option buttons let you specify whether a reference to the input image or a deep copy of the input image is displayed for the LastRun.InputImage. You can also specify that no image be displayed.

  • Show Region displays the input region as defined in Current.InputImage buffer (or in the Region tab).