Example Code

Calculate Intensity Center of Mass of Particles Using the Vision Development Module

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 find particles and calculate the centroids of those particles.

 

Description
The 'IMAQ Particle Analysis' function will only operate on a binary image. Thus, the center of mass calculation returned is based upon all of the pixels in the particle having the same intensity (again since the function operates on a binary image).  However, the particle analysis function can still be used to calculate the center of mass for a particle while taking into consideration the varying intensities of the pixels in a particle.

 

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. Compare the slight difference between the green (default center of mass) and the red markers (intensity sensitive centroids)

 

Additional Information or References

IMAQ Find Particles and Calc Centroids LV2012 NIVerified.vi - Front Panel.png

 

IMAQ Find Particles and Calc Centroids 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

 

Remark:

A previous version of this example uses an own algorithm for calculating the center of mass (centroid). Since there is already a standard function in the VDM called 'IMAQ Centroid' that does the same thing, the algorithm was replaced by the standard function.

 

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

Cole R.
National Instruments
Software Engineer

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