Re: Problem with variables in memory [message #79974] |
Fri, 20 April 2012 12:58 |
Jeff[2]
Messages: 18 Registered: November 2007
|
Junior Member |
|
|
Thanks for the messages.
In fact, that's a "good" problem, but I just wanted to know why does
that happen. I agree with you, it really sounds like a optimization
and not a memory issue.
That's weird, if I close IDL and open again and run the code with any
x and y pairs that I had previously used the extraction is pretty
fast.
All the best!
|
|
|
Re: Problem with variables in memory [message #79975 is a reply to message #79974] |
Fri, 20 April 2012 11:58  |
Brian Daniel
Messages: 80 Registered: July 2009
|
Member |
|
|
On Friday, April 20, 2012 2:02:14 PM UTC-4, Esquerdo wrote:
> I have a problem with variables in memory (I guess)... sorry, it's a
> beginner question.
>
> I'm using the "envi_get_slice" to extract slice profiles from a
> hyperspectral image with 270 bands.
>
> For exemple, in order to get the spectral slice of the 10th line and
> the 5th column I use:
>
> spectral_profile = envi_get_slice(fid=fid, pos=indgen(273), line=10,
> xe=5, xs=5)
>
> Although it takes some time (there are 270 bands!), it works fine.
> However, if I run again the code without changing the x and y (line
> and column) the extraction is very very quick!
>
> I tried to use ".reset_session" before running the second time, but it
> doesn't work. As I am studying the speed of this extraction process I
> need to measure the real time.
>
> Does anyone has any tips to reset variables without leaving IDL?
>
> Thanks
ENVI_GET_DATA versus ENVI_GET_SLICE is an issue I've run into often. My unsupported theory is that it has to do with the interleave of the image. For my applications I work with BIP and ENVI_GET_SLICE is faster. Now, why does ENVI work faster the second time around given the same x and y? Most likely ENVI has filled a buffer with the data already. ENVI has quite a few optimizations under the hood to speed up processing. If it didn't, no one would use their API.
Other than this being a funky behavior, why should this be a problem?
|
|
|
Re: Problem with variables in memory [message #79976 is a reply to message #79975] |
Fri, 20 April 2012 11:22  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Esquerdo writes:
> I have a problem with variables in memory (I guess)... sorry, it's a
> beginner question.
>
> I'm using the "envi_get_slice" to extract slice profiles from a
> hyperspectral image with 270 bands.
>
> For exemple, in order to get the spectral slice of the 10th line and
> the 5th column I use:
>
> spectral_profile = envi_get_slice(fid=fid, pos=indgen(273), line=10,
> xe=5, xs=5)
>
> Although it takes some time (there are 270 bands!), it works fine.
> However, if I run again the code without changing the x and y (line
> and column) the extraction is very very quick!
>
> I tried to use ".reset_session" before running the second time, but it
> doesn't work. As I am studying the speed of this extraction process I
> need to measure the real time.
>
> Does anyone has any tips to reset variables without leaving IDL?
I am not absolutely sure about this, but I doubt this
is a memory issue. I *think* what is happening is that
ENVI stores its data in a "convenient" form for what you
want to do with it.
When you tell it you want to get a pixel value through a lot
of bands, it thinks "Oh oh, I got that wrong!" and reorganizes
its data (part of why this is taking so long, I think) so that
the *next* time you ask for this, the data is organized in a way
that make this process very fast.
You might find that now asking ENVI to display a "band" of the image
might be slow while it reorganizes to that particular thing.
Don't know. I'm no ENVI expert. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|