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

deb otrov@hush...
Thu Dec 27 14:20:39 CST 2012


Hi,

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?
TIA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20121227/61733c25/attachment.html 


More information about the NumPy-Discussion mailing list