[Python] Interpolation CT scan in python

Discussão em 'Python' iniciado por Stack, Abril 3, 2025.

  1. Stack

    Stack Membro Participativo

    I have a CT scan with a shape of (350, 512, 512) and a voxel size of (2, 1.13, 1.13).

    I would like to do an interpolation to get a new voxel size of (1,1,1) by using zoom from scipy.

    Here is the code I am using

    volume = np.stack([dcm.pixel_array for dcm in dicom_files]).astype(np.uint16) #3D volume with original data
    volume = volume * slope + intercept #convert to Hounsfield Units
    full_ct_spacing = [slice_thickness, pixel_spacing[0], pixel_spacing[1]] #shape of a voxel
    new_spacing = np.array([1,1,1]) #target spacing
    resize_factor = full_ct_spacing / new_spacing #resize factor
    volume = zoom(volume.astype(np.uint16), resize_factor, order=1, mode='reflect') #interpolated volume


    I get a new CT scan with a shape of (700, 580, 580) but when I dislay it the grey levels seem to be reversed. Air is white and bones are black.

    Is it due to the zoom function ? What is the best way to interpolate CT scan ?

    Continue reading...

Compartilhe esta Página