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

Home » Public Forums » archive » Re: Array statistics
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: Array statistics [message #9776] Mon, 11 August 1997 00:00
J.D. Smith is currently offline  J.D. Smith
Messages: 214
Registered: August 1996
Senior Member
David R. Klassen wrote:
>
> I was wondering if there were an easy way to take a 2-D array
> and create a new array of the same size/dimension but where
> each pixel is the variance of some subset of itself and surrounding
> pixels.
>
> In other words, I'm looking for something akin to the SMOOTH
> function but instead of doing a boxcar average, does a "boxcar
> variance".
>
> --
> David R. Klassen


You can do this with the smooth method itself, since the variance is the
average of the square deviation (up to an n-1):

bw2=box_width^2
;; compute the boxcar average
avg=smooth(image,box_width)
;; compute square deviation
dev=(image-avg)^2
;; compute the boxcar variance (average square deviation)
var=smooth(dev,box_width)*bw2/(bw2-1)

I strongly suggest using the nasa routine filter_image in place of
smooth or median for boxcar statistics (average or median) since it
takes care of edges, given the keyword ALL_PIXELS. Note, if you want to
calculate variance *not including* the central pixel (my preferred
method):

avg=(smooth(image,box_width)*bw2-image)/(bw2-1)
dev=(image-avg)^2
var=(smooth(dev,box_width)*bw2-dev)/(bw2-2)

Good luck.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Using LINKIMAGE with IDL 4.0.1 runtime license
Next Topic: Array statistics

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

Current Time: Wed Oct 08 13:42:26 PDT 2025

Total time taken to generate the page: 0.00551 seconds