[GRASS-user] implementing frost filter in grass

Hi,

I'm trying to implement the FROST [0] SAR despeckling filter in a
GRASS script. The code according to the referenced link is below:

#########
The implementation of this filter consists of defining a circularly
symmetric filter with a set of weighting values M for each pixel:

M = exp(- A * T)

where:

               A = DAMP * (V / I**2)

       T is the absolute value of the pixel distance
                   from the centre pixel to its neighbours in
                   the filter window

       DAMP is the exponential damping factor

       V is the variance of the grey-level in
                   the filter window

       I**2 is the square of the mean grey level in the
                   filter window

The resulting grey-level value R for the smoothed pixel is:

        R = (P1*M1 + P2*M2 + ... + Pn*Mn) / (M1 + M2 + ... + Mn)

where:

        P1 .. Pn are grey levels of each pixel in filter window

        M1 .. Mn are weights (as defined above) for each pixel
#########

Computing for A is straightforward using r.mapcalc. I'm having
difficulty in deriving T which was defined as "the absolute value of
the pixel distance
from the centre pixel to its neighbours in the filter window"

I investigated r.cost and r.distance but it is not suited for a moving
window operation (perhaps I'm wrong). It maybe possible r.mapcalc's
row-column offset
but it will loose the ability to interactively define a window size.

Any tips on how to get the T and final R values? Advance thanks!

[0] http://web.archive.org/web/20071216081728/http://www.pcigeomatics.com/cgi-bin/pcihlp/FFROST

--
cheers,
maning
------------------------------------------------------
"Freedom is still the most radical idea of all" -N.Branden
wiki: http://esambale.wikispaces.com/
blog: http://epsg4253.wordpress.com/
------------------------------------------------------