[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: efficient kernel or masking algorithm ? UPDATE*From*: John-David Smith <jdsmith(at)astro.cornell.edu>*Date*: Sun, 25 Feb 2001 22:00:04 -0500*Newsgroups*: comp.lang.idl-pvwave*Organization*: Cornell University*References*: <Kocm6.25536$MN.621469@news2-win.server.ntlworld.com>*Sender*: verified_for_usenet(at)cornell.edu (jts11 on d6053.dialup.cornell.edu)*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:23660

Martin Downing wrote: > > From thread: http://cow.physics.wisc.edu/~craigm/idl/archive/msg03957.html > 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!

**Follow-Ups**:**Re: efficient kernel or masking algorithm ? UPDATE***From:*Martin Downing

**Re: efficient kernel or masking algorithm ? UPDATE***From:*Martin Downing

**Re: efficient kernel or masking algorithm ? UPDATE***From:*Martin Downing

**References**:**Re: efficient kernel or masking algorithm ? UPDATE***From:*Martin Downing

- Prev by Date:
**Re: !EXCEPT** - Next by Date:
**Re: efficient kernel or masking algorithm ? UPDATE** - Prev by thread:
**Re: efficient kernel or masking algorithm ? UPDATE** - Next by thread:
**Re: efficient kernel or masking algorithm ? UPDATE** - Index(es):