Snehal Jadhav
Snehal Jadhav

Reputation: 1

DICOM Image segmentation and 3d construction using VTK

I am working on .dcm image (dicom image)

In my case there are 152 2D image slices.

I have used https://www.raddq.com/dicom-processin... link for segmentation . After segmentation, i used region of interest(ROI) on that segmented area.

Now i have parameters x,y,w,h and crop image which is getting from ROI.

I want to visualize this segmented data in 3D using VTK library with python .

Is there any way to visualize this data. I am confused what will be the function and parameters of vtk.

Upvotes: 0

Views: 3888

Answers (2)

Dave Chen
Dave Chen

Reputation: 2085

In addition to @user3216191's suggestion, you could take a look at itkwidgets:

https://github.com/InsightSoftwareConsortium/itkwidgets

It is a Python package enables you to volume render a 3d image in a Jupyter notebook. It can take as input ITK image, a numpy array or some other 3d image formats. It will also render 3d meshes in VTK or ITK mesh formats.

I don't know if it will volume render both your original image and your segmentation. So you could extract an isosurface of the segmentation and display that with a volume rendering of the original image.

Upvotes: 0

user3216191
user3216191

Reputation: 123

Looking at that tool, the output of segmentation is stored as a numpy array. In order to use common image visualization tools, you need to store that array into a more generic 3D format.

You could use SimpleITK or itk-python to import numpy array into an ITK image. You can find the specific recipe how to do this and store the result into a file here: https://itkpythonpackage.readthedocs.io/en/latest/Quick_start_guide.html#mixing-itk-and-numpy.

One thing that will be missing in the file you save is the geometry information about the image. Probably the easiest way to address this is to first convert the input DICOM image series into 3D format (you can do this using dcm2niix that will store the resulting volume as NIfTI), load that volume into Python using the aforementioned SimpleITK or itk-python, which will also give you the option to export the loaded image into a numpy array. If you start with that array for your segmentation task, the arrangement of voxels in the segmentation numpy array will be the same as in the image numpy array. So when you export numpy array into a SimpleITK or itk-python image, you can copy image geometry to initialize segmentation geometry (you will need to use Get/SetDirection, Get/SetSpacing and Get/SetOrigin).

Once you store it in a file, you can use tools such as 3D Slicer to load the original DICOM image series, and overlay segmentation results.

Unfortunately, it's a lot of steps, and I understand this will be confusing. But hope it will help you get started!

Upvotes: 3

Related Questions