comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: save an IDLanROI to file? (newbie question)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: save an IDLanROI to file? (newbie question) [message #40776] Thu, 26 August 2004 08:36
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeff writes:

> Saving the data size info before the actual data is a neat trick, wish
> I'd thought of it :)

Well, after I hit the SEND button I realized I really
didn't show you the neatest trick of all. The data
array should really be created with the Make_Array
function like this:

OpenR, lun, filename, /Get_LUN
sizeInfo = LonArr(5)
ReadU, lun, sizeInfo
data = Make_Array(Size=sizeInfo)
ReadU, lun, data
Free_Lun, lun

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: save an IDLanROI to file? (newbie question) [message #40778 is a reply to message #40776] Thu, 26 August 2004 08:12 Go to previous message
jnettle1 is currently offline  jnettle1
Messages: 27
Registered: January 2001
Junior Member
Thanks David!

Saving the data size info before the actual data is a neat trick, wish
I'd thought of it :)

Jeff
Re: save an IDLanROI to file? (newbie question) [message #40784 is a reply to message #40778] Wed, 25 August 2004 21:15 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Jeff writes:

> I need to save an IDLanROI object (returned by XROI) to a file
> programmatically. I know how to compute a mask and save that, but I'd
> like to save the actual ROI data too, just to be safe. Should I be
> thinking about making a .sav file?

Well, creating a save file is certainly something you
should *consider*, but whether you should use it or
not often depends on other factors. There are problems
restoring objects in general. See this for example:

http://www.dfanning.com/tips/saved_objects.html

Although you are not likely to run into these problems
with IDLanROI objects. Probably the *next* object you
try to save. :-)

In any case, I often find it more convenient to just
get the information I need from an object (e.g, the
data) and save that in a regular binary data file.
Then I can easily read the data file and recreate
an object when I need it.

The only trick is to be sure to put enough information
in the data file so you can read it again. Something
like this:

myROI -> GetProperty, Data=theData
filename = Dialog_Pickfile(File='myroi.dat', /Write)
IF filename NE "" THEN BEGIN
Obj_Destroy, myROI
OpenW, lun, filename, /Get_LUN
WriteU, lun, Size(data), data
Free_Lun, lun
ENDIF

Then, when you want to read it:

filename = Dialog_Pickfile(File='myroi.dat', /Write)
IF filename NE "" THEN BEGIN
OpenR, lun, filename, /Get_LUN
sizeInfo = LonArr(5)
ReadU, lun, sizeInfo
data = FltArr(sizeInfo[1], sizeInfo[2])
ReadU, lun, data
Free_Lun, lun
myRoi = Obj_New('IDLanROI', data)
ENDIF

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: linetool for measuring the distance between 2 points
Next Topic: Re: linetool for measuring the distance between 2 points

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Nov 28 10:05:30 PST 2025

Total time taken to generate the page: 0.56288 seconds