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

Home » Public Forums » archive » Re: Variance in sub-sections?
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: Variance in sub-sections? [message #29383 is a reply to message #29381] Mon, 18 February 2002 07:41 Go to previous messageGo to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
Senior Member
Joshua Nipper wrote:

> I have a 512x512 image, and I would like to calculate the mean/variance
> in a 3x3 neighborhood around every pixel. What would be the easiest way
> to do this w/out for loops?

For the mean, you can use smooth() : m = smooth( img, 3 ).
Or using convol:
k = ( intarr( 3, 3 ) + 1 ) / 9.0 ; 3x3 kernel, all elements set to 1/9
m = convol( img, k )

The variance is total( (x_mean-x_i)^2 ) / n, so just subtract the mean
image, square all elements, and use convol() to sum up 3x3 local pixels
around each element:

v = convol( (img-m)^2, k )

Alex
--
Alex Schuster Wonko@netcologne.de
alex@pet.mpin-koeln.mpg.de
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: broken country borders in map_continents
Next Topic: Re: debug IDL DLM in Visual C++

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

Current Time: Sun Oct 12 05:49:47 PDT 2025

Total time taken to generate the page: 1.60516 seconds