-1

I have 3D volume medical image of size [284,143,143]. I want to extract axial slices from them and save them separatley in a folder. Can anyone tell me how can I acheive this in python.

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
CS.Enthu
  • 1
  • 3
  • 1
    What kind of images are these 3D volume medical image? Are these multi-frame DICOM images or something else? And what is the original image orientation (e.g. do you have to reformat them to get axial slices)? – MrBean Bremen Jun 27 '20 at 17:55

1 Answers1

1

I'm not sure if this is what you're look for but you can always use numpy and slice while indexing. (I'm assuming your image is a PIL image because of the tag)

import numpy as np
from PIL import Image

...`

arr = np.array(PIL_Image)
for i in range(284):
    slice = Image.fromarray(arr[i, :, :])
    slice.save(f"slice{i}.jpg")
Adi Mehrotra
  • 150
  • 1
  • 7