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