I have a 3D array of binary data. I want to project this to 3 2D images - side on, head on, birds eye.
I have written the code:
for x in range(data.s
You can compute it as follows:
>>> data = np.random.random_sample((200, 300, 100)) > 0.5
>>> data.any(axis=-1).shape # show the result has the shape we want
(200, 300)
>>> data.any(axis=-1)
array([[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True],
...,
[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True],
[ True, True, True, ..., True, True, True]], dtype=bool)
>>>
You can scale values if you need
>>> data.any(axis=-1) * 255
array([[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255],
...,
[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255],
[255, 255, 255, ..., 255, 255, 255]])
>>>