[Numpy-discussion] "moving window" in numpy
meine at informatik.uni-hamburg.de
Mon Nov 26 03:04:38 EST 2007
On Montag 26 November 2007, Matthew Perry wrote:
> Hi all,
> I'm not sure if my terminology is familiar but I'm trying to do a
> "moving window" analysis (ie a spatial filter or kernel) on a 2-D
> array representing elevation. For example, a 3x3 window centered on
> each cell is used to calculate the derivate slope of that cell.
Did you have a look at ndimage?
> Currently I have tried implementing in pure python loops (too slow)
You could probably have a faster, pure python version with some indexing
tricks. E.g. if your gradient filter is static (i.e. the weights do not
adapt to the local image content), you can apply it to whole images that
contain shifted image contents. This way, you're using the fast C loops of
Ciao, / / .o.
/ / ANS ooo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the NumPy-Discussion