Qazi Sami Ullah Khan
Qazi Sami Ullah Khan

Reputation: 11

how to get an axial image from ct scan images. as i am using sliver07 dataset so it has 100+ images in single .mhd file

i using SLIVER07 dataset for liver segmentation task but i am stuck in reading that images.

import SimpleITK as sitk
import numpy as np
import matplotlib.pyplot as plt

# reading .mhd file from slive07 dataset 
itkimage = sitk.ReadImage('liver-orig001.mhd')
ct_scan = sitk.GetArrayFromImage(itkimage)
plt.imshow(ct_scan[1])

Upvotes: -1

Views: 314

Answers (1)

Robbie
Robbie

Reputation: 4872

You are trying to pass the entire 3D image volume to imshow. You could instead try:

plt.imshow(ct_scan[40,:,:])

Which will show the 40th slice.

Of interest might be the platipy library, available here, or just $ pip install platipy. The built-in image visualiser (based on matplotlib) is perfect for 3D image visualisation in python, and has lots of cool features.

A little demo:

from platipy.imaging import ImageVisualiser

img = sitk.ReadImage("image_filename.mhd")

vis = ImageVisualiser(img)
fig = vis.show()

ortho_slices_with_platipy

Upvotes: 2

Related Questions