0

I have this numpy array of slices of segments of the liver CT(ground truths). I want to export them into a viewable format in tools like blender. The slices are white and black, 0-255. Anything other than liver is black, I want the liver to be viewed in 3d.

The slices are in top view. I used this code in kaggle to view them but just in jupyter https://www.kaggle.com/akh64bit/full-preprocessing-tutorial/data. It can be any way to visualize them.

dark1sider
  • 45
  • 1
  • 9
  • Do you have a specific issue? Stack Overflow is not a free code writing service, eh. – AMC Jan 11 '20 at 01:00
  • 1
    [This question](https://blender.stackexchange.com/q/48919/935) may provide some insight. Using 2.79 blender render supports an image sequence for [voxel data](https://docs.blender.org/manual/en/2.79/render/blender_render/textures/types/volume/voxel_data.html). You may also create vertices out of your array and use the [point density node](https://docs.blender.org/manual/en/2.81/render/shader_nodes/textures/point_density.html). – sambler Jan 12 '20 at 04:14

2 Answers2

1

You may try transform your arrays to DICOM format as mentioned before in stackoverflow: Create pydicom file from numpy array

Than you can easily visualize DICOM images in various platforms!

1

For new folks stumbling upon this question that are looking to convert pixels / voxels to an STL file or files, this Python workflow has worked for me:

  1. Load stack of images as a 3D NumPy array using imageio.imread().
  2. Segment the foreground from the background using one of the many segmentation algorithms from the scikit-image submodule skimage.segmentation, creating a 3D binary image.
  3. Use the marching cubes algorithm from the scikit-image submodule skimage.measure to convert the voxels of interest to a list of faces defined by vertices on the surface of the volume.
  4. Use numpy-stl to create an stl.Mesh object from the list of faces and vertices (as done in this example) then save the mesh with stl.Mesh.save().

As a bonus, you can use the Python package for the Open3D library to open & view multiple STL files!

Gus B
  • 147
  • 1
  • 10