3

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

Royal
  • 95
  • 1
  • 7
  • What is different about these images? – jkr Mar 25 '21 at 13:54
  • @Royal can you please share the [minimal-reproducible-example](https://stackoverflow.com/help/minimal-reproducible-example) including a sample Nifti image so we can test your code on your image and understand your problem? otherwise `show` function in `OpenCV` and `Matplotlib` do the same thing in general! – Bilal Mar 27 '21 at 06:07
  • Hello I added the nifti image and the pictures I obtain with matplotlib and opencv. – Royal Mar 30 '21 at 14:42

0 Answers0