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 =
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
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