Re: Passing Image Data :) [message #27326 is a reply to message #27324] |
Fri, 19 October 2001 12:56   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Logan Lindquist (llindqusit@mrdoc.cc) writes:
> Since everyone was so helpful last time, I figured I'd give this
> another shot. I read in the [Mr. Fanning's IDL PT 1st ed.] that
> it is better to use Struct's ( info = { imageData:imageData} )
> to pass common program information between pro/functions rather
> than the IDL 'common' keyword. Well I am having problems doing
> that. I would like to make it so it doesn't matter what
> type[2, 3, or 4 dimensional] of image I pass between pro/functions.
> I might try making a image data variable for each type, but
> that seems redundant. My original thinking was to make a
> dummy ByteArr and then resize it, if need be, but that didn't work.
>
> I tried several different variable initializations, even making
> it so that it was the same as the returned image and it still
> gives me an error saying that the expressions are not the same.
> I think I am just going to rewrite it so that the image data is
> passed using the common keyword. Does the common keyword make a
> pointer? Do I have to release this from memory, or does IDL
> handle that? Now that I think of it, that might be better,
> cause it would be faster if I could just create one instance
> of the image data in memory rather than copying and pasting
> it between parts of the program. So I guess what the question
> really is, What is the quickest [best] way to pass image data
> of varying dimensions between program components?
Oh, oh. I'd better send you the 2nd Edition of the book. :-(
What you want in your info structure image field is a pointer
to the image:
info= { image:Ptr_New(myimage), ...}
Then, you don't have to worry about the size or dimensionality
of the image. When you want a new image placed there, you just
do this:
*info.image = newimage
IDL takes care of all the memory management for you. You don't
have to worry about it.
If you display your image with TVIMAGE or IMDISP, then
you also don't have to worry about size and dimensionality:
TVImage, *info.image
You also learn in the 2nd edition how to make the
*info* structure a pointer, if you are brave enough
for that. :-)
Cheers,
David
P.S. Let's just say if you want a book, give me a call.
Anyone who calls me Mr. Fanning gets a *huge* discount. :-)
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|