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 
Return to the default flat view Create a new topic Submit Reply
Re: newbie: sub-array extraction [message #45813 is a reply to message #45808] Thu, 13 October 2005 21:17 Go to previous messageGo to previous 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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
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: Fri Nov 28 19:04:34 PST 2025

Total time taken to generate the page: 1.69166 seconds