Note
Click here to download the full example code
Layer manipulator (plugin)
An example controlling the layer manipulator, using napari-threedee as a napari plugin.
Out:
/home/runner/work/napari-threedee/napari-threedee/src/napari_threedee/utils/napari_utils.py:64: FutureWarning: Private attribute access ('Window._qt_window') in this context (e.g. inside a plugin widget or dock widget) is deprecated and will be unavailable in version 0.6.0
qt_viewer = viewer.window._qt_window._qt_viewer
/home/runner/work/napari-threedee/napari-threedee/src/napari_threedee/utils/napari_utils.py:64: FutureWarning: Private attribute access ('_QtMainWindow._qt_viewer') in this context (e.g. inside a plugin widget or dock widget) is deprecated and will be unavailable in version 0.6.0
qt_viewer = viewer.window._qt_window._qt_viewer
/home/runner/work/napari-threedee/napari-threedee/src/napari_threedee/utils/napari_utils.py:65: FutureWarning: Access to QtViewer.view is deprecated since 0.5.0 and will be removed in the napari 0.6.0. Change to QtViewer.canvas.view instead.
return qt_viewer.view.scene
import napari
try:
from skimage.data import binary_blobs
except ImportError:
raise ImportError("This example requires scikit-image. pip install scikit-image")
image = binary_blobs(
50,
n_dim=3,
blob_size_fraction=0.3,
volume_fraction=0.1,
)
viewer = napari.view_image(
image,
colormap="magenta",
opacity=0.8,
blending="additive",
rendering="iso",
iso_threshold=0,
name="image_0",
)
image_layer_0 = viewer.layers[0]
# add an addition layer that is shifted
image_layer_1 = viewer.add_image(
image.copy(),
colormap="green",
opacity=0.8,
blending="additive",
rendering="iso",
iso_threshold=0,
name="image_1",
translate=(20, 20, 20),
)
viewer.dims.ndisplay = 3
viewer.window.add_plugin_dock_widget(
plugin_name="napari-threedee", widget_name="layer manipulator"
)
napari.run()
Total running time of the script: ( 0 minutes 5.281 seconds)
Download Python source code: layer_manipulator_plugin.py