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

Highlighted Overlays for various ROIs

Code and Documents

Attachment

Overview

As of LV2015, the only overlays that can be highlighted are rectangles. The NI discussion forums and community has various threads discussing some ways to highlight other ROIs but I could not find any that were successful. I created a VI that uses the IMAQ library to highlight any ROI via a pixel-by-pixel method of "rectangles".

Description

The example (LV2012) highlights any given ROI you draw on a loaded image. If your process is time-sensitive, you will want to keep an eye on the processing time this takes. Depending on the shape you can make the algorithm much more efficient than pixel-by-pixel overlays. For the large red shape, it took 280ms to draw pixel-by-pixel on my laptop... so clearly not efficient on time. However, the program could be modified to highlight larger regions of pixels for significant improvement in execution time. I leave that part up to you!


Steps to Implement or Execute Code

  1. The IMAQ library is required.
  2. Run the attached VI
    1. Press the "Open Image" button to select any image on which you want to draw an ROI. Note that I only tested this with 8-bit greyscale images.
    2. Draw an ROI on the image using the standard Image Controls Pallete.
    3. Choose a color and press the "Highlight ROI" button. The algorithm will draw highlighted rectangles pixel-by-pixel for the ROI you specify.
    4. Press the "Clear Overlays" button to clear all overlays.
  3. Press the Stop button to stop the VI execution when done.

Requirements

Software

Labview 2012 (or later)

Vision Development Module 2012

Hardware

NA

Additional Images or Video

Highlight ROIs.png

screenshot of block diagram.png


Chris Walker
Certified Labview Developer

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

Comments
Sam2009
Member
Member
on

Awesome write up Chris.

 

 

Contributors