Copy Region Tool Edit ControlCognex VisionPro

This topic contains the following sections.

The Copy Region tool edit control provides a graphical user interface to the CogCopyRegionTool tool, which you use to copy a portion of an input image to a new output image, copy a portion of an input image into an existing destination image, or fill a portion of an input region with a constant grey value. See the topic Copy Region Tool for more information on how to use a Copy Region tool.

The Copy Region tool accepts all supported image types including 16-bit encoded images, allowing you to use and generate images with a bit depth of 8-bits, 10-bits, 12-bit, 14-bits and 16-bits.

Note: The output image's coordinate space tree is adjusted to preserve the relationship between root space and image features.

The following figure shows the Copy Region tool edit control:

Cognex Image Processing Copy Region Copy Region 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 function tabs allow you to choose whether to copy pixels from the input image or fill an output image with a constant value (greyscale or color), determine the type of input region you want to use, and select an alignment that controls how the input image maps to the output image.
  • An image display window displays acquired images and the output image the Copy Region tool generates.

When you add a new Copy Region tool to a QuickBuild application, it appears with the input terminals for the input image, the destination image, and the output image, as shown in the following figure:

Cognex Image Processing Copy Region Copy Region Terminals

To include the edit control in your custom vision application, you must first add it to your Visual Studio.NET development environment. See the topic Adding Edit Controls to Visual Studio for more information.

Control Buttons

Cognex Image Processing Copy Region Copy Region Tool Button Bar

The following table describes the function of each button:

Table 1. Control buttons
ButtonDescriptionFunction
Run Button
RunGenerate an output image based on the dimensions of the input region and current parameters.
Electric Button
Electric modeToggle electric mode, where the Copy Region 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 Copy Region tool supports the following image buffers:

  • The Current.InputImage buffer contains the next image the tool will analyze plus the graphic for the input region.
  • The Current.DestinationImage buffer contains an optional image into which the tool will copy the contents of the input region specified within the Current.InputImage buffer. If the Region Shape is anything other than the entire image then the buffer also contains a graphic representing the region of the destination image that will be overwritten by the tool.
  • The LastRun.InputImage buffer contains the last image processed by the Copy Region tool along with any graphics you enable.
  • The LastRun.OutputImage buffer contains the output image the tool produces.
Floating Display Button
Floating image displayOpen a floating image window, which supports 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 vision tool to a VisionPro persistence (.vpp) file. The edit control allows you to choose between saving the vision 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.
Settings Tab

This section contains the following subsections.

Use the Settings tab to determine whether the output image contains pixels from the input image or a constant greyscale or color value, and how the tool handles pixels outside the input region but within the borders of the region bounding box. The following figure shows the default Settings tab:

Cognex Image Processing Copy Region Copy Region Settings Tab

Inside Region

Cognex Image Processing Copy Region Copy Region Settings Tab Inside Region

Use the following options to determine whether the output image contains pixels from the input image or a constant grey value:

Table 2. Inside Region
ParameterDescription
FillRegionTake pixels from the input region of the input image for copying to the output image.

FillRegion

Fill the output image with a constant greyscale or color value, based on the input region you use as well as the format of the input image.

If you are using greyscale images, specify the FillRegionValue.

If you are using color images, specify values for FillRegionPlane0Value, FillRegionPlane1Value, and FillRegionPlane2Value, which correspond to separate planes for Red, Green and Blue in RGB images, or Hue, Saturation and Intensity in HSI images.

Default Output Image Type

Cognex Image Processing Copy Region Default Output Image Type

Specify the type of DefaultOutputImageType you want to generate when you choose to fill in pixels of the input region with a constant greyscale or color value.

Outside Region, Within Bounding Box

Cognex Image Processing Copy Region Copy Region Settings Tab Outside Region

Use the following options to configure how the tool handles pixels outside a circular, elliptical, or affine rectangle region of interest but within an enclosing rectangle and you are using a region mode of Pixel Aligned Bounding Box Adjust Mask:

Table 3. Outside Region
ParameterDescription

FillBoundingBox

If you are not using a destination image, this option fills pixels outside the region but within the enclosing bounding box with uninitialized values. If you are using a destination image, however, this option allows the pixels outside the region to retain the values of the underlying destination image.

FillBoundingBox

Fill in pixels outside the region but within the bounding box with a constant greyscale or color value, based on the input region you use as well as the format of the input image.

If you are using greyscale images, specify the FillBoundingBoxValue.

If you are using color images, specify values for FillBoundingBoxPlane0Value, FillBoundingBoxPlane1Value, and FillBoundingBoxPlane2Value, which correspond to separate planes for Red, Green and Blue in RGB images, or Hue, Saturation and Intensity in HSI images.

Region Tab

Use the Region tab to select the shape of the input region. The following figure shows the Region tab:

Cognex Image Processing Copy Region Copy Region Region Tab

Use the following options to configure the input region:

Table 4. Region Tab Options
FeatureDescription

RegionMode

Defines one of the following types of input regions:

  • Pixel Aligned Bounding Box encloses the defined region within a rectangle. This means that the portions of the image that are outside the defined region but within the bounding rectangle are included.
  • Pixel Aligned Bounding Box Adjust Mask encloses the defined region within a rectangle, but masks out the image portions that are outside the region but inside the enclosing rectangle. The result is that the defined region is closer to what you specify.
Region ShapeThe shape of the copy region. Selecting "None=Use entire image" means that the entire input image becomes the region. The set of region-defining parameters depends on the selected Region Shape.
SelectedSpaceNameThe coordinate space in which the copy 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.
Alignment Tab

The Copy Region tool allows you to copy the input region of the input image and paste it into the contents of some destination image. By default, the input image and the destination image align themselves at the top-left corner of each image, at image coordinate (0,0) in the current coordinate space. This alignment causes the input region to be placed in the destination image at the same location it uses in the input image.

Use the Alignment tab of the Copy Region edit control to specify a different alignment between the two images. For example, if you specify a coordinate of (25, 25) for the input image and leave the alignment point on the destination image at (0, 0), then the tool aligns the input image at point (25, 25) with the point (0, 0) in the destination image. This, in turn, causes the input region to appear in the destination image offset with respect to its location in the input image.

The settings in this tab have no effect if you do not provide the tool with a destination image. The following figure shows the default Alignment tab:

Cognex Image Processing Copy Region Copy Region Alignment Tab

Use the following parameters to align the images:

Table 5. Alignment Parameters
ParameterDescription
ImageAlignmentEnabledEnable a particular alignment of the input image with the destination image. By default, the tool aligns the images at coordinate (0, 0) of each image.

Input Image Alignment

Use the InputImageAlignmentX and InputImageAlignmentY fields to specify the point in the input image you want to use to align the images.

Click the Fit In Input Image button to move the alignment point to the center of the input image.

Destination Image Alignment

Use the DestinationImageAlignmentX and DestinationImageAlignmentY fields to specify the point in the destination image you want to use to align the images.

Click the Fit In Destination Image button to move the alignment point to the center of the destination image.

Graphics Tab

This section contains the following subsections.

Use the Graphics tab to specify the graphics that the tool generates and displays. The following figure shows the Graphics tab:

Cognex Image Processing Copy Region Copy Region Graphics Tab

Results

Cognex Image Processing Copy Region Copy Region Graphics Tab Results

Enable either of the following options:

Table 6. Result Options
OptionDescription
Show Output ImageYou can choose not to generate an image record for the LastRun.OutputImage.
Show Destination RegionYou can enable a graphic in the LastRun.OutputImage representing the region of the image that was overwritten by the tool, based on the input region and alignment settings.
Diagnostics

Cognex Image Processing Copy Region Copy Region Graphics Tab Diagnostics

Enable any of the following options:

Table 7. 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 Source RegionEnable a graphic representing the input region for the LastRun.InputImage.
Show Image Alignment PointsEnable graphics for the input region and the point of alignment over the destination image for the LastRun.InputImage and the LastRun.OutputImage. These are visible only if alignment is enabled..