def octahedron(radius, dtype=np.uint8):
 n = ((2 * radius) + 1)
 (Z, Y, X) = np.mgrid[(- radius):radius:(n * 1j), (- radius):radius:(n * 1j), (- radius):radius:(n * 1j)]
 s = ((np.abs(X) + np.abs(Y)) + np.abs(Z))
 return np.array((s <= radius), dtype=dtype)

def octahedron ( radius , dtype = np . uint8 ) : n = ( ( 2 * radius ) + 1 ) ( Z , Y , X ) = np . mgrid [ ( - radius ) : radius : ( n * 1j ) , ( - radius ) : radius : ( n * 1j ) , ( - radius ) : radius : ( n * 1j ) ] s = ( ( np . abs ( X ) + np . abs ( Y ) ) + np . abs ( Z ) ) return np . array ( ( s <= radius ) , dtype = dtype )
generates a octahedron-shaped structuring element .