Re: Getting number of neighbours for a 3d numpy arrays

2016-07-12 Thread Nobody
Some common ways to handle the boundary condition: 1. Generate clamped indices, test for validity and substitute invalid entries with an "identity" element. E.g. ijk = np.mgrid[:a,:b,:c] i,j,k = ijk i0,j0,k0 = np.maximum(0,ijk-1) i1,j1,k1 = np.minimum(np.array(a,b,c).T-1,ijk+1) n1 =

Re: Getting number of neighbours for a 3d numpy arrays

2016-07-12 Thread Peter Otten
Heli wrote: > I have a 3d numpy array containing true/false values for each i,j,k. The > size of the array is a*b*c. > > for each cell with indices i,j,k; I will need to check all its neighbours > and calculate the number of neighbour cells with true values. > > A cell with index i,j,k has the

Getting number of neighbours for a 3d numpy arrays

2016-07-12 Thread Heli
Hi, I have a 3d numpy array containing true/false values for each i,j,k. The size of the array is a*b*c. for each cell with indices i,j,k; I will need to check all its neighbours and calculate the number of neighbour cells with true values. A cell with index i,j,k has the following