Example Code

Centroid of an 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 calculate a centroid of the portion of an IMAQ image.

 

Description
In order to find the centroid of a portion of an image a ROI (region of interest) can be used to define the desired portion of the IMAQ image. Since the 'IMAQ Centroid' function does not support ROIs the ROI has to be converted to a image mask before. Masks isolate a part of an image for processing.

 

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. Run the VI
  2. Select any available ROI (region of interest) tool and create a ROI and click OK

 

Additional Information or References

IMAQ Calculate Centroid of ROI LV2012 NIVerified.vi - Front Panel.png

 

IMAQ Calculate Centroid of ROI LV2012 NIVerified.vi - Block Diagram.png

 

How Does the IMAQ Centroid VI Work?
http://digital.ni.com/public.nsf/allkb/4F4947441856350B86256B3E0074FD39

Region Of Interest Frequently Asked Questions (FAQ)
http://digital.ni.com/public.nsf/allkb/82C6023BCC87F5CA86256F38006D2C98

 

**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.**

National Instruments
Senior Systems Engineer

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

Comments
WNM
Active Participant
Active Participant
on

This example only works with 8-bit image data due to a long standing and occasionally reviled weakness of the "IMAQ ROIToMask 2" function.  The example would have been more useful if it instead shows the gyrations one must go through to work with any image bit depth.