Hi,

On 16 August 2012 19:38, Sebastian Berg <[email protected]> wrote:

> Hello,
>
> Just to throw it in, if you do not mind useing scipy, you can use its
> multidimensional correlate method instead:
>

Well, I don't need to count the number of neighbours as in the linked
example. What I wanted to have is easy access to the neighbours of one
cell, so

neighbours = np.array( [GRID[up,:], GRID[down,:], GRID[:,up], GRID[:,down]
, \
        GRID[ix_(up,up)], GRID[ix_(up,down)], GRID[ix_(down,up)] , \
        GRID[ix_(down,down)] ])

That gives me an array of shape (8,)+GRID.shape. neighbours.sum(axis=1) (I
think) would give me the equivalent of scipy.ndimage.correlate (I think),
but I don't necessarily need a sum or a mean value of the neighbours. It's
just that a 3D neigbourhood is 9 +8 +9 = 26 neighbours for each pixel, and
I was wondering whether there was a simpler way of writing it than what I
had in my message, which is likely to have errors.

Thanks!
Jose
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to