I am attempting to create an array in the shape of a cylinder to mask a 3D numpy array. The goal is to remove an outer ring in the image. The image is of size 1648x1648x1420. I have figured out how to construct the cylinder and apply it element wise but I am covering up my image instead. How can I get a result opposite of this?
import numpy as np
import matplotlib.pyplot as plt
import nrrd
seg,header = nrrd.read("image.nrrd")
x = np.linspace(-10, 10, 1658)
y = np.linspace(-10, 10, 1658)
z = np.linspace(-10, 10, 1420)
x,y,z = np.meshgrid(x,y,z)
x0 = 3
y0 = 2
z0 = 3
mask = (x-x0)**2 + (y-y0)**2 > (z-z0)**2
maskimg = plt.imshow(mask[:,:,100],cmap="gray")
plt.show()
z_masked = np.multiply(mask,seg)
zimg_masked = plt.imshow(z_masked[:,:,200])
plt.show()