
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? http://www.scipy.org/SciPyPackages/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 NumPy. -- Ciao, / / .o. /--/ ..o / / ANS ooo