ROIs generated programmatically are usually saved to a pre-defined cluster called ROI Descriptor. To select a part of ROIs of an ROI group, in other words, to get a subset needs a rule to identify which one is selected. Being inside a region is a useful and convenient rule that can be set manually with the image display control.
The IMAQ image display control provides some tools on the tool palette for "selecting an area of the image", as in the following figure. You can use these tools to easily draw a region on the displayed image.Notes:
Although it is ROI as well, this ROI (named control ROI) belongs to the display control, but not to the IMAQ image overlay (named generated ROI).
The following VI snippet and steps will show you how to use the rectangle ROI tool of IMAQ image display control to select a subset of generated ROI. These steps assume you already have a VI with IMAQ image display control on the front panel and a set of image ROIs in an ROI Descriptor.
- Display the generated ROIs by overlay them on an IMAQ image. You can use IMAQ Overlay ROI at Vision and Motion>>Vision Utilities>>Overlay for that.
- Add a control ROI by the rectangle ROI tool on the image display control. You can add a while loop or event structure in diagram to wait for this user operation.
- Use property node of the IMAQ image display control to get the ROI Descriptor of the control ROI.
- Ungroup the generated ROIs into ROI Descriptor array, using IMAQ Ungroup ROIs at Vision and Motion>>Vision Utilities>>Region of Interest. The array is easier to index and identify one by one.
- Compare the boundaries of generated ROI and control ROI, and use the conditional index of for-loop to pick out the generated ROIs that are inside the control ROI. This identification logic can only process rectangular control ROI.
- Clear the overlay set at Step 1, and then overlay the re-grouped selected ROI to display. These function VIs used here can be found at Vision and Motion>>Vision Utilities>>Region of interest and Vision and Motion>>Vision Utilities>>Overlay subpanels.
- The Selected ROI Descriptor contains only the selected ROIs. You can use it in the subsequent process.