How to process only few slices of a 3D dicom image

Hi All,

I have a use case where given a 3D dicom image, I wish to apply for the filters only on selected slices. For example if 3D image has depth of 52 slices I want to apply Segmentation filters only from slice number 20 to slice number 30. How can I create an image out of these 10 slices so that I can apply Segmentation only on new image created out of these 10 slices image.


Perhaps this will do the trick

or this


If you can identify to which files on disk do your slices of interest correspond to, you could copy only those slices into a new directory and open it as different image. This might, or might not be what you want to do.

Thanks this may work I will try it out and provide my findings and observation s!

Yup I would also need to save range of slices and a new image at later stage in post processing! Thanks

Extract image filter does the trick!! Thanks much guys!!

In SimpleITK it’s really easy to extract a subset of an image using python’s array slicing.

For example, this is how you could extract slice # 20:

import SimpleITK as sitk
image1 = sitk.Image(100,100,100,sitk.sitkUInt8)
image2 = image1[20]

or if you want to extract a range of slices:

image3 = image1[20:30]