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 
Return to the default flat view Create a new topic Submit Reply
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
[Message index]
 
Read Message
Read Message
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: Fri Oct 10 17:36:58 PDT 2025

Total time taken to generate the page: 0.56611 seconds