I am working with a nifti image that I converted into a numpy array. This is the code, I've done to obtain the edge of the picture:
import ants
img = ants.image_read("image.nii.gz")
img_numpy = img.numpy()
# For the edge detection
sx=ndimage.sobel(img_numpy,axis=0,mode='constant')
sy=ndimage.sobel(img_numpy,axis=1,mode='constant')
edge=np.hypot(sx,sy)
And the original image: After detecting the edges of the picture, I want to create a mask inside of those edges.
This is the pictures with edges detection:
And this is the mask I want to obtain (I draw the mask on LIFEx):
I've seen a lot of this done on OpenCV but sadly I didn't found a way to use OpenCV with nifti pictures so I am using numpy instead.
Thanks
Ps: Here is link for the numpy array that I use: img_array, here is link for the original nifti image: nifti image