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

Home » Public Forums » archive » Re: Read _ tiff with Sub_Rect Keyword
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Read _ tiff with Sub_Rect Keyword [message #44995 is a reply to message #44876] Wed, 27 July 2005 12:28 Go to previous message
Chris[2] is currently offline  Chris[2]
Messages: 39
Registered: August 2003
Member
Couldn't you eliminate the loop entirely using stride?

image[*, *, m] = a[*,0:samples-1:xper+1]

Or, even better, since you are inserting the "a" array into a contiguous
block of memory in "image", you can just use 0,0 as the subscripts:

image[0, 0, m] = a[*,0:samples-1:xper+1]

This will insert the entire "a" subarray into "image", starting at position
[0,0]. This is *much* faster than using index ranges, or even the *'s,
because IDL doesn't have to compute the locations internally. It just copies
the data as one block.

One other point. I think you want just "xper" in your loop, not "xper+1".
And finally, if your image isn't a multiple of "xper", your array indexing
will run off the end. So I think you really want to compute ximg and yimg
as:
ximg = (samples + xper - 1)/xper
yimg = (lines + yper - 1)/yper

-Chris


<meinel@aero.org> wrote in message
news:1122383746.592213.326040@g44g2000cwa.googlegroups.com.. .
> Isn't it more efficient to write
>
> for j =0 ,samples-1,xper+1 do begin
> image[0:2,k,m] = a[0:2,j]
> k++
> endfor
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Displaying 2D arrays
Next Topic: Read _ tiff with Sub_Rect Keyword

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

Current Time: Sun Oct 12 17:08:16 PDT 2025

Total time taken to generate the page: 1.75965 seconds