Example Code

Extract Image Parts Based On A ROI (NI 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

This example demonstrates how to extract parts of an image based on a user defined ROI (Region of Interest).

 

Description

This example code enables you to extract parts of an image based on a ROI. You can use any type of ROI with this example. You are not limited to the rectangle ROI.

If you use a ROI which creates a closed area, the extract image contains the image inside the ROI. If you use a ROI which doesn't creates a closed area, the resulting image only contains the pixels under der contour of the ROI.

This example takes your ROI and converts it into a mask. This mask is used to mask out any pixels which are not part of the ROI. After this step, the example cuts out the image based in the bounding rectange of the ROI.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • NI Vision Development Module 2012 (or compatible)
  • If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

Steps to Implement or Execute Code

  1. Download and open the attached ZIP-file
  2. Open and run the VI

 

Additional Information or References

 

NOTE: This VI is compatible with the following file types, all others will result in error: PNG, JPG, JPEG, JPG2000, TIFF or BMP.

 

Extract Image Parts Based On ROI - Front Panel.png
Extract Image Parts Based On ROI - Block Diagram.png

 

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

National Instruments

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

Comments
The_Happy_Coder
Member
Member
on

Hi Michelle_B

I’m new to LabVIEW and even newer to the Vision Development Module.  I understand what you say about the non-rectangular RoI not returning a non-rectangular RoI.

In your experience (or indeed that of anyone else reading this) is it possible to use or modify this technique or any other to just extract the pixel values of the region you are interested in?

Context: I have an image and in it lies a disc of varying intensity; its position and size will vary.  I would like to highlight the disc and output the statistics for it.

Kind regards,

Chris

Michelle_N
Active Participant
Active Participant
on

Hi Chris,

This is probably not the best place to get your question answered - repost your question here: http://forums.ni.com/t5/Machine-Vision/bd-p/200

it's our Machine Vision discussion forums, they are generally very active so you should get a response from someone in the community this way.

Cheers,

Michelle

--Michelle

National Instruments
fjimage
Member
Member
on

thank you for offering methods to crop image by using this development version. can i ask if i use it. how to activate licese key in this situation.

Michelle_N
Active Participant
Active Participant
on

Hi there,

 

You need to have Vision Development Module: https://www.ni.com/en/shop/data-acquisition-and-control/add-ons-for-data-acquisition-and-control/wha...

You get a license with a purchase of this module.

--Michelle

National Instruments
Nardimes
Member
Member
on

how can i make extracted roi more visualised