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

Home » Public Forums » archive » Re: make a vector from all pixels in a moving window
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: make a vector from all pixels in a moving window [message #74526] Sat, 22 January 2011 16:28
envi35@yahoo.ca is currently offline  envi35@yahoo.ca
Messages: 48
Registered: March 2005
Member
On Jan 22, 6:59 pm, Robin Wilson <ro...@rtwilson.com> wrote:
> Hi Jenny,
>
> I use the function below to do this for me. It might not be the most
> efficient way of doing it (my IDL code is often lacking in terms of
> efficiency), but it works:
>
> FUNCTION GET_LOCAL_SUBSET, n, x, y, arr
>    ; This gets the local n x n window around the given x and y values
>    ; It will repeat edge values as needed to provide the correctly sized
>    ; return array
>    ;
>    ; Altered fromhttp://michaelgalloy.com/2006/10/10/local
>    ; grid-points.html (Original Author: Michael Galloy)
>    ;
>    ; Calculate the offsets
>    offsets = lindgen(n) - (n - 1) / 2
>
>    ; Calculate the offsets from the given x and y values
>    xoffsets = reform(rebin(offsets, n, n), n^2)
>    yoffsets = reform(rebin(offsets, n^2), n^2)
>
>    return, reform(arr[x + xoffsets, y + yoffsets],n,n)
> END
>
> See Michael's blog post (linked in the comments above) for more
> information on how it works.
>
> Hope this helps,
>
> Robin

This is just what I need! Thanks! Robin
Re: make a vector from all pixels in a moving window [message #74527 is a reply to message #74526] Sat, 22 January 2011 15:59 Go to previous message
Robin Wilson is currently offline  Robin Wilson
Messages: 40
Registered: August 2010
Member
Hi Jenny,

I use the function below to do this for me. It might not be the most
efficient way of doing it (my IDL code is often lacking in terms of
efficiency), but it works:

FUNCTION GET_LOCAL_SUBSET, n, x, y, arr
; This gets the local n x n window around the given x and y values
; It will repeat edge values as needed to provide the correctly sized
; return array
;
; Altered from http://michaelgalloy.com/2006/10/10/local
; grid-points.html (Original Author: Michael Galloy)
;
; Calculate the offsets
offsets = lindgen(n) - (n - 1) / 2

; Calculate the offsets from the given x and y values
xoffsets = reform(rebin(offsets, n, n), n^2)
yoffsets = reform(rebin(offsets, n^2), n^2)

return, reform(arr[x + xoffsets, y + yoffsets],n,n)
END

See Michael's blog post (linked in the comments above) for more
information on how it works.

Hope this helps,

Robin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: make a vector from all pixels in a moving window
Next Topic: Re: Making a 64 bit DLM

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

Current Time: Wed Oct 08 15:16:12 PDT 2025

Total time taken to generate the page: 0.00476 seconds