Region of Interest (ROI) Manipulations

Contents

Description

You can use ROIs to focus your processing and analysis on part of an image. For example, the histogram shown in the example below is only calculated for the area of the image specified by the green ROI rectangle. You can trace an ROI using standard contours (oval, rectangle, and so forth) or free contours (freehand). These tools are available whenever you place an image indicator on the front panel.  

You can add multiple ROIs to the same image holding Ctrl while using the mouse to place an ROI. Notice how the Histogram changes to reflect the contents of the multiple new ROIs.

You can also perform any of the following options:

  • Associate an ROI with an image window
  • Extract an ROI associated with an image window
  • Erase the current ROI from an image window
  • Transform an ROI into an image mask and vice versa
  • Transform overlays into ROIs and vice versa

Using Image Masks

An image mask is an 8-bit image of the same size as or smaller than the image to process. Pixels in the mask determine whether the corresponding pixel in the image needs to be processed. If a pixel in the mask is non-zero, the corresponding pixel in the image to process is processed. If a pixel in the image mask has a value of 0, the corresponding pixel in the image to process is left unchanged.

The image mask can be limited to the bounding rectangle of the shape you want to mask. This technique is used to save memory, limiting the image mask to only the part containing information. To keep track of the location of this ROI in regard to the original image, IMAQ Vision sets a specific record of the image mask called an offset.

The following figure shows how an offset defines the upper-left corner coordinates (x, y) for the bounding rectangle belonging to the ROI. The default value of the offset is (0, 0).



The ROI Descriptor Definition (advanced) 

The ROI Descriptor cluster contains the following two elements:

  1. Global Rectangle: This is a bounding rectangle that completely encloses the ROI. It is specified by an array of 4 points.
  2. Contours: This is an array of clusters containing the following 3 elements:
    • contour type: 0 specifies an exterior contour and 1 specifies an interior contour
    • ROI type: point, line, rectangle, oval, freehand, and so on
    • list of points: (x, y) describing the contour

The ROI descriptor can be used to add ROIs to an image display control, or modify existing ROIs programmatically. You can return the ROI Descriptor associated with an image display by using a property node.

Common Applications

  • Reducing computation time by limiting the processing area
  • Identifying line profiles for edge detection and circular profiles for rotation detection or pattern matching
  • Identifying text areas for optical character recognition (OCR).

Was this information helpful?

Yes

No