[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: STANDARD DEVIATON
I wrote:
> It's possible I'm missing something
and then, about four seconds after I hit the submit button,
realised what it was I was missing: for a corner pixel of any given
9x9 area my method subtracts the mean of a different 9x9 area centred
on the corner pixel.
Still, my method is about twenty times faster than Ben_imageSD
which in turn is about four times faster than IDL_imageSD, so there's
a lot of incentive to find a hack.
The traditional way to speed up the loops would be to buffer the
calculation of the running average. For example, instead of adding
elements i-1, i, and i+1 of each row you remember the sum from last
time, subtract i-2 and add i+1. With a 9-element kernal this won't
help a lot, but it will a bit.
If you're not too worried about edge effects (and your posted code
wasn't), you could always create nine copies of the (float(image) -
localmean) array from my function, each with the localmean array
shifted by different amounts (use the SHIFT function to avoid
recalculation). Then you'd just have to shift them back to line up
the pixels, square them and take the sum. This could be done as a
loop over the 9x9 kernal elements if you don't have the memory or disk
space to hold all the copies in memory at once.
Struan