Plot binary images
def visualize3Dimage(image):
'''
the 1s are plotted, the zeroes not.
requires binary images
'''
x, y, z = np.where(image == 1)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Plot the '1's in the image
ax.scatter(x, y, z, c='red', marker='o')
# Set labels and show the plot
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
# Set axis limits to match the image shape
ax.set_xlim([0, image.shape[0]])
ax.set_ylim([0, image.shape[1]])
ax.set_zlim([0, image.shape[2]])
plt.show()