I have a 3D numpy array with shape of (400, 512, 512)
, and I have bounding box, for example:
[376, 250, 206]
[380, 256, 211]
Now, I want to crop the bounding box area from the array and visualize. Normally in 2D array/image we can crop using the min max value like:
img[y:y + h, x:x + w]
But I don't think it's like that in 3D array, as the z axis is also involved. Can anyone suggest any example how to crop an area from a 3D numpy array using min max bounding box coordinates? In the end I will fit a cylinder in extracted bounding box area.
Edit: I want all the indices and their intensity values inside the bounding box of the main big 3D array. I can do like:
big_3d_array[z1:z2, x1:x2, y1:y2]
where,
z1 = 376, z2 = 380, x1 = 250, x2 = 256, y1=206, y2= 211
Now problem with this approach is that I get the intensity values only, can not get the indices. Also I am not sure whether I am getting all the coordinates inside the bounding box using this approach. Because in 3d space bounding box should have 8 corner points. Here I only have the min max of the bounding box.