Skip navigation

Community

Currently Being Moderated

Programmatically Create Polygon Region of Interest (ROI) and Mask

VERSION 1 
Created on: Nov 9, 2012 10:51 AM by Daniel_H1 - Last Modified:  Nov 9, 2012 11:07 AM by Daniel_H1

Description:
This VI shows how you would convert a series of points (x-pixel, y-pixel) into a polygon ROI and an image mask. You could use this to programmatically create your ROI or Mask from the results of other machine vision functions. For example, if you used pattern matching to find several items in your image, you could use their locations to programmatically create the ROI and mask.

 

This was created in LabVIEW 2012, with NI-IMAQ 4.7. A version saved for LabVIEW 2009 is also attached.

 

Instructions:
1) Download the attached "sample poly ROI.vi"

2) Click the folder on the "Image Path" control in order to browse. Select an image you want to view.

3) Run the VI

4) Modify the points to alter the ROI and Mask

 

Block Diagram Steps:

1) Load an image from file

2) Extract the ROI

3) Unbundle the "Contours" array of clusters, then index out the first contour

4) Create the image that will be used for creating the mask

5) Define the points for the polygon. The points are in the format of (X-pixel, Y-pixel), where (0,0) is the top-left pixel.

6) Concatenate the Points into a 1D array

7) Bundle the Poins array into the Contour cluster

8) Write the new ROI information back to the image property node

9) Create and display the mask, using the ROI to define the Mask

 

poly roi mask block diagram.png

 

poly roi mask front panel.png

Attachments:
Comments (4)