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

Home » Public Forums » archive » Re: Rapid "moving windows" access in IDL?
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: Rapid "moving windows" access in IDL? [message #37845 is a reply to message #37844] Thu, 29 January 2004 22:01 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Jonathan Greenberg <greenberg@ucdavis.edu> writes:
> I'm trying to code a semivariance measure to analyze an image in IDL. Since
> the call requires extracting data from a matrix a certain distance away from
> the center pixel, is there a fast way of coding IDL to extract these
> locations, or is am I doomed to have a very slow algorithm. Basic gist:
>
> For a given pixel/matrix location, subtract off the value of the pixels
> surrounding that pixel:
>
> For pixel at A is at x,y
> B at x-1,y
> C at x+1,y
>
> Semivariance = ((A-B)^2 + (A-C)^2)/4
>
> Any suggestions?

Yes, how about

N = n_elements(A(*,0)) ;; Number of pixels per row
B = A(0:N-3,*) ; "left" pixel
Amid = A(1:N-2,*) ; "middle" pixels
C = A(2:N-1,*) ; "right pixels

semivariance = ((Amid-B)^2 + (Amid-C)^2)/4

Of course this array will have an row size of two less than the
original. People who know me, also know that you can avoid some of
the steps above by using a "trick" where IDL will automatically
truncate arrays if they are too big, which means you can write the
whole thing as:

Amid = A(1:*,*)
semivariance = ((Amid-A)^2 + (Amid-A(2:*,*))^2)/4

which is more cryptic, but it saves me from the tragic pain of
figuring out what "N" is.

Happy semi-variancing,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Memory Headache II
Next Topic: Incremental variable names?

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

Current Time: Sat Oct 18 20:06:59 PDT 2025

Total time taken to generate the page: 1.11928 seconds