From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Extracting a Freeshape ROI

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Vision Development Module
  • LabVIEW

Code and Documents

Attachment

Overview

The example demonstrates how to extract a free shape ROI and mask the image with that ROI.

 

Description

A ROI or region of interest is used to select the important area of an image for processing. ROIs can be used to greatly reduce image processing time. Recall that LabVIEW currently supports rectangular images; this means that image data must be stored in 2D array/ matrix form. This example describes the most robust means of extracting ROIs.


What happens when users want to use a freeform, non-rectangular, ROI?
The most common method of extracting an ROI is creating an ROI descriptor using the rectangle selection tool and the IMAQ Construct ROI(VI), from here the ROI is extracted from the original using IMAQ extract tetragon(VI). Freeform ROI descriptors are also made using IMAQ Construct ROI(VI). In order to extract non rectangular ROIs special steps are taken and are described in this example.

 

Requirements

 Software

  • LabVIEW 2012 Base Development System (or compatible)
  • Vision Development Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Open the attached file
  2. (Optional) Change the path to the preset image in the block diagram (step 1)
  3. Run the VI
  4. Select a ROI in the dialog shown with any of the tools
  5. Click OK
  6. See the result in the image control

 

Additional Information or References

Dialog VI that is displayed after the VI is launched

Extract Freeshape ROI - Front Panel GUI 1.png

 

Main VI

Extract Freeshape ROI - Front Panel 2.png

 

Extract Freeshape ROI - Block Diagram.png

 

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text 'NIVerified'. Read here for more information about the new Example Guidelines and Community Platform.**


Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.