Create 2D axial slices from 3D vol of medical image

Hello everyone.
I have a 3D volume of medical data storred as numpy array of size [284,143,143]. Now I want to slice the images axially and save them in tiff format. How can I acheive that. Can someone please give an example.

Thanks

You could iterate the tensor, index each sample, transform it to PIL.Image and store it.
Here is a small code snippet:

import torchvision.transforms.functional as TF

x = torch.randn(5, 24, 24)
for idx in range(x.size(0)):
    tmp = x[idx]
    img = TF.to_pil_image(tmp)
    img.save('img{}.tiff'.format(idx))

Thank you :slight_smile: