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

Home » Public Forums » archive » Re: newbie: sub-array extraction
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: newbie: sub-array extraction [message #45800] Sun, 16 October 2005 15:02 Go to next message
Ben  Rogers is currently offline  Ben Rogers
Messages: 2
Registered: October 2005
Junior Member
Thanks Dick,

much appreciated!
Re: newbie: sub-array extraction [message #45808 is a reply to message #45800] Fri, 14 October 2005 09:20 Go to previous messageGo to next message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Another tip for the self-announced newbie: in Online Help under Contents,
find:

Programmer's Guides
Building IDL Applications
Application Programming
Writing Efficient IDL Programs

Lots of good stuff for the new IDL user.

Cheers,
-Dick

"Dick Jackson" <dick@d-jackson.com> wrote in message
news:WjG3f.179148$1i.83985@pd7tw2no...
> Hi Ben,
>
> "Ben Rogers" <ben.jordanrogers@gmail.com> wrote in message
> news:1129254169.767522.77270@g43g2000cwa.googlegroups.com...
>> [...] I am looking to extract a 5x5 array around a central pixel to
>> calculate some background statistics. Is this something best
>> acomplished with for loops or is there an idl function that does
>> something similar already?
>
> Certainly. The section in Online Help that you might want is "subscripts",
> but here's an example for you.
>
> nX = 10
> nY = 10
> array = BIndGen(nX, nY)
>
> pixX = 4
> pixY = 6
>
> subArray = array[pixX-2:pixX+2, pixY-2:pixY+2]
> Print, subArray
>
> ... and I get:
>
> 42 43 44 45 46
>
> 52 53 54 55 56
>
> 62 63 64 65 66
>
> 72 73 74 75 76
>
> 82 83 84 85 86
>
> To be more careful, truncating the array if the pixel[X|Y] is too close to
> the edge:
>
> pixX = 1
> pixY = 9
>
> subArray = array[(pixX-2)>0:(pixX+2)<(nX-1), (pixY-2)>0:(pixY+2)<(nY-1)]
> Print, subArray
>
> ... and I get:
>
> 70 71 72 73
>
> 80 81 82 83
>
> 90 91 92 93
>
> Hope this helps!
>
> Cheers,
> --
> -Dick
>
> Dick Jackson / dick@d-jackson.com
> D-Jackson Software Consulting / http://www.d-jackson.com
> Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
>
Re: newbie: sub-array extraction [message #45813 is a reply to message #45808] Thu, 13 October 2005 21:17 Go to previous messageGo to next message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
Hi Ben,

"Ben Rogers" <ben.jordanrogers@gmail.com> wrote in message
news:1129254169.767522.77270@g43g2000cwa.googlegroups.com...
> [...] I am looking to extract a 5x5 array around a central pixel to
> calculate some background statistics. Is this something best
> acomplished with for loops or is there an idl function that does
> something similar already?

Certainly. The section in Online Help that you might want is "subscripts",
but here's an example for you.

nX = 10
nY = 10
array = BIndGen(nX, nY)

pixX = 4
pixY = 6

subArray = array[pixX-2:pixX+2, pixY-2:pixY+2]
Print, subArray

... and I get:

42 43 44 45 46

52 53 54 55 56

62 63 64 65 66

72 73 74 75 76

82 83 84 85 86

To be more careful, truncating the array if the pixel[X|Y] is too close to
the edge:

pixX = 1
pixY = 9

subArray = array[(pixX-2)>0:(pixX+2)<(nX-1), (pixY-2)>0:(pixY+2)<(nY-1)]
Print, subArray

... and I get:

70 71 72 73

80 81 82 83

90 91 92 93

Hope this helps!

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
Re: newbie: sub-array extraction [message #45925 is a reply to message #45808] Wed, 19 October 2005 11:59 Go to previous message
gqshen2008@gmail.com is currently offline  gqshen2008@gmail.com
Messages: 9
Registered: October 2005
Junior Member
This document is what I am looking for, thank you!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Waiting without locking?
Next Topic: Re: Quick question regarding "where" function

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

Current Time: Wed Oct 08 15:54:10 PDT 2025

Total time taken to generate the page: 0.00527 seconds