Note
Go to the end to download the full example code.
Interactive animation#
Display a labels layer above of an image layer using the add_labels and add_image APIs

/home/runner/work/napari-animation/napari-animation/examples/interactive_animation.py:15: FutureWarning: `napari.view_image` is deprecated and will be removed in napari 0.7.0.
Use `viewer = napari.Viewer(); viewer.add_image(...)` instead.
viewer = napari.view_image(blobs.astype(float), name='blobs')
from skimage import data
from scipy import ndimage as ndi
import napari
blobs = data.binary_blobs(length=128, volume_fraction=0.1, n_dim=3)
viewer = napari.view_image(blobs.astype(float), name='blobs')
labeled = ndi.label(blobs)[0]
viewer.add_labels(labeled, name='blob ID')
viewer.window.add_plugin_dock_widget(plugin_name='napari-animation')
napari.run()
Total running time of the script: (0 minutes 1.966 seconds)