For a recent project, I needed to compute a local mean and standard deviation for an array. Given a window size, the local mean for a given pixel location is the mean of all the elements around that pixel in the window. So the local mean is an array the same size as the original image. The local mean is simple to calculate:

kernel = fltarr(width, width) + 1.0
local_mean = convol(image, kernel) / width^2

for a window size of width. But I wasn’t sure if I could calculate the local standard deviation or other moments beyond the mean (without a loop) since they have a power of x[j] - mean[i] term. It turns out that you can with some tedious algebra; it’s fairly straightforward to calculate.

The IDL routine MOMENT can also calculate mean absolute deviation. I haven’t been able to come up with a way to compute a local mean absolute deviation without a loop.

Here is (doc).