OpenCv for NifTi files Python

Viewed 680

I want to use openCV to create a mask for my Nifti pictures. I found how to show one picture with plot but not with openCV. Sadly I still haven't figured how.

This is the link to the nifti image

I tried this:

img = nib.load(r'mypicture.nii.gz')
image_data = img.get_fdata()

height, width, depth = image_data.shape
print(height, width, depth)

plt.imshow(image_data[:, :, 50], cmap='gray')
plt.axis('off')
plt.show()

I obtain this: image obtained with matplotlib

But when I tried to do with openCV:

cv.imshow('T1', image_data[:, :, 50])
cv.waitKey(0)

This is what I obtain with open CV

Also, I wanted to know if it's possible to do a 3D threshold with open CV

0 Answers
Related