Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving ROI of an image in a file

I want save the ROI position selected by the user in a file, and then reload from the file and display the ROI contour on the new image.
0 Kudos
Message 1 of 4
(5,940 Views)
This is pretty easy to do.

To save the ROI, just open a file and use the write file vi. You can wire the ROI data directly to the data input of the vi.

To load the ROI, open the file and use the read file vi. You will need to wire an empty ROI to the data type, and the output will be the ROI you saved earlier.

Use get ROI and set ROI to interact with the display.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 4
(5,940 Views)

How does one wire an empty ROI up? I am pretty new to Labview, so please be explicit.

 

Here is what I have so far. It is going to be part of a larger program that will allow a user to use the last mask/ROI or draw a new one. The new ROI will be saved and loaded next time the program runs. An ROI will always load on program startup, though

 

Load_Save_ROI.png

 

Thanks for the help.

 

-Chris

-Chris
0 Kudos
Message 3 of 4
(5,135 Views)

If you save the image as PNG, you can flatten the ROI to string, then save that string as custom data within the PNG file IMAQ Write Custom Data. No need for an additional file to save the ROI next to your image.

When you write the file select PNG with Vision Info.

To read the file back, make sure you use IMAQ Read Image and Vision Info, then IMAQ Read Custom Data, and unflatten from string to read the ROI back.

 

-Christophe

0 Kudos
Message 4 of 4
(5,129 Views)