I have a stack of 100 images of size 300 x 300 which represent a 3D volume. I have another 100 of these 3D volumes as a sequence. I have been trying to visualize this 3D image sequence data as a video where I can watch how the volume is changing over time and move around the scene to see the changes in the volume from different views.
I tried doing this in matplotlib but it only works on 3D point data and I could not figure out how to make it visualize a 3D stack of images as a video. I also did not see support for this in mayavi or plotly and I was wondering if there is a package that can do this visualization out of the box? I would like to see the video sequence As MIP and if possible to slice through them.
You can try using the napari library python library.
You can install napari
using pip install napari
. Here's the installation guide.
Note: You need to be on python 3.8 or greater.
I wrote a sample script with randomly generated noise as images:
import napari
import numpy as np
# Randonmly generated a images
image_sequence = np.random.randint(0, 255, size=(100, 300, 300), dtype=np.uint8)
viewer = napari.Viewer()
viewer.add_image(image_sequence)
viewer.layers[0].rendering = 'mip' # Maximum Intensity Projection (MIP)
viewer.dims.ndisplay = 3
napari.run()
To get the player click Toggle ndisplay button on the bottom left of the napari window or press Ctrl+Y.