[Numpy-discussion] Manipulate neighboring points in 2D array

deb otrov at hush.ai
Thu Dec 27 15:20:39 EST 2012


I have 2D array, let's say: `np.random.random((100,100))` and I want
to do simple manipulation on each point neighbors, like divide their
values by 3.

So for each array value, x, and it neighbors n:

n n n    n/3 n/3 n/3
n x n -> n/3  x  n/3
n n n    n/3 n/3 n/3

I searched a bit, and found about scipy ndimage filters, but if I'm
not wrong, there is no such function. Of course me being wrong is
quite possible, as I did not comprehend whole ndimage module, but I
tried generic filter for example and browser other functions.

Is there better way to make above manipulation, instead using for loop
over every array element?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20121227/61733c25/attachment.html>

More information about the NumPy-Discussion mailing list