Example #1
0
"""
Display one markers layer ontop of one 4-D image layer using the
add_markers and add_image APIs, where the markes are visible as nD objects
accross the dimensions, specified by their size
"""

import numpy as np
from skimage import data
from napari import ViewerApp
from napari.util import app_context

with app_context():
    # TODO: change axis back to 0 once dims displayed in sane order
    blobs = np.stack([
        data.binary_blobs(
            length=128, blob_size_fraction=0.05, n_dim=3, volume_fraction=f)
        for f in np.linspace(0.05, 0.5, 10)
    ],
                     axis=-1)
    viewer = ViewerApp(blobs.astype(float))
    # add the markers
    markers = np.array([[100, 100, 0, 0], [50, 120, 0, 0], [100, 40, 1, 0],
                        [110, 20, 100, 2], [400, 100, 10, 8]])
    viewer.add_markers(markers,
                       size=[10, 10, 6, 0],
                       face_color='blue',
                       n_dimensional=True)
Example #2
0
"""
Display one markers layer ontop of one image layer using the add_markers and
add_image APIs
"""

import numpy as np
from skimage import data
from skimage.color import rgb2gray
from napari import ViewerApp
from napari.util import app_context

print("click to add markers; close the window when finished.")

with app_context():
    viewer = ViewerApp(rgb2gray(data.astronaut()))
    markers = viewer.add_markers(np.zeros((0, 2)))
    markers.mode = 'add'

print("you clicked on:")
print(markers.coords)
Example #3
0
import numpy as np
from skimage import data
from skimage.color import rgb2gray
from napari import ViewerApp
from napari.util import app_context

with app_context():
    # create the viewer and window
    viewer = ViewerApp()

    # add the image
    viewer.add_image(rgb2gray(data.astronaut()))
    # add the markers
    markers = np.array([[100, 100], [200, 200], [333, 111]])
    size = np.array([10, 20, 20])
    viewer.add_markers(markers, size=size)

    # unselect the image layer
    viewer.layers[0].selected = False

    # adjust some of the marker layer properties
    layer = viewer.layers[1]

    # change the layer name
    layer.name = 'spots'

    # change the layer visibility
    layer.visible = False
    layer.visible = True

    # change the layer selection