/
02_layer_list.py
31 lines (24 loc) · 989 Bytes
/
02_layer_list.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from skimage import data
import napari
with napari.gui_qt():
viewer = napari.Viewer()
# each image is stacked on a layer list (it should be a layer stack =D)
# we assign a label to each layer so that we can recover it easily later
viewer.add_image(data.astronaut(), name='astronaut')
viewer.add_image(data.moon(), name='moon')
viewer.add_image(data.camera(), name='camera')
# we can access the layers
#
# viewer.layers[key]
#
# key can be the key/label assigned to the layer or
# an index (integer value)
#
# `viewer.layers` has type LayerList, which is a list-like layer collection
# with built-in reordering and callback hooks.
# A layer with an image has the type: napari.layers.image.image.Image
# or 'Image layer'
# To remove a layer, just use:
# viewer.layers.pop(i)
# All these codes can be used in the built-in interactive terminal
# of Napari, which already has all loaded data on memory