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

Home » Public Forums » archive » Re: efficient kernel or masking algorithm ? UPDATE
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: efficient kernel or masking algorithm ? UPDATE [message #23919 is a reply to message #23918] Sun, 25 February 2001 19:00 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Martin Downing wrote:
>
> From thread: http://cow.physics.wisc.edu/~craigm/idl/archive/msg03957.htm l
> a.. Date: Wed, 29 Nov 2000 16:30:54 -0500
> Richard Tyc wrote:
>>
>> I need to apply a smoothing type kernel across an image, and calculate the
>> standard deviation of the pixels masked by this kernel.
>>
>> ie. lets say I have a 128x128 image. I apply a 3x3 kernel (or simply a
>> mask) starting at [0:2,0:2] and use these pixels to find the standard
>> deviation for the center pixel [1,1] based on its surrounding pixels, then
>> advance the kernel etc deriving a std deviation image essentially.
>> I can see myself doing this 'C' like with for loops but does something
> exist
>> for IDL to do it better or more efficiently ?
>>
>> Rich
>
> I was wandering through new Craig's IDL archive site (which is brilliant by
> the way) and came across this question asking for an efficient way of
> calculating the loacal standard deviation in an array. It seemed to me that
> the thread had not reached a full solution so perhaps some of you might be
> interested in this method which is very fast. It is based on the crafty
> formula for variance:
> variance = (sum of the squares)/n + (square of the sums)/n*n

Righto. I knew I was fishing for something like this. Except I think you mean:

(population) variance = (sum of the squares)/n - (square of the sums)/n*n

Luckily, that's how you've coded it too. Sample variance (=population
variance*n/(n-1)) is of course the more common case in science (as opposed to
gambling).

JD

P.S. I think I originally got the idea from sigma_filter.pro, a NASA library
routine, dating back to 1991. It's chock-full of other good tidbits too.
Thanks Frank and Wayne!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Input/output Errors
Next Topic: contour_plus using Coyote Graphics System (CGS)

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

Current Time: Fri Oct 10 03:57:09 PDT 2025

Total time taken to generate the page: 1.28475 seconds