How to use the napari.layers.Labels function in napari

To help you get started, we’ve selected a few napari examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github napari / napari / napari / _qt / layers / util.py View on Github external
from ...layers import Image, Labels, Points, Shapes, Surface, Vectors
from .qt_image_layer import QtImageControls
from .qt_points_layer import QtPointsControls
from .qt_shapes_layer import QtShapesControls
from .qt_labels_layer import QtLabelsControls
from .qt_surface_layer import QtSurfaceControls
from .qt_vectors_layer import QtVectorsControls


layer_to_controls = {
    Image: QtImageControls,
    Labels: QtLabelsControls,
    Points: QtPointsControls,
    Shapes: QtShapesControls,
    Surface: QtSurfaceControls,
    Vectors: QtVectorsControls,
}


def create_qt_controls(layer):
    """
    Create a qt controls widget for a layer based on its layer type.

    Parameters
    ----------
        layer : napari.layers._base_layer.Layer
            Layer that needs its controls widget created.
github napari / napari / napari / components / viewer_model.py View on Github external
Path or list of paths to image data. Paths can be passed as strings
            or `pathlib.Path` instances.

        Returns
        -------
        layer : :class:`napari.layers.Labels`
            The newly-created labels layer.
        """
        if data is None and path is None:
            raise ValueError("One of either data or path must be provided")
        elif data is not None and path is not None:
            raise ValueError("Only one of data or path can be provided")
        elif data is None:
            data = io.magic_imread(path)

        layer = layers.Labels(
            data,
            is_pyramid=is_pyramid,
            num_colors=num_colors,
            seed=seed,
            name=name,
            metadata=metadata,
            scale=scale,
            translate=translate,
            opacity=opacity,
            blending=blending,
            visible=visible,
        )
        self.add_layer(layer)
        return layer
github napari / napari / napari / components / viewer_model.py View on Github external
Translation values for the layer.
        opacity : float
            Opacity of the layer visual, between 0.0 and 1.0.
        blending : str
            One of a list of preset blending modes that determines how RGB and
            alpha values of the layer visual get mixed. Allowed values are
            {'opaque', 'translucent', and 'additive'}.
        visible : bool
            Whether the layer visual is currently being displayed.

        Returns
        -------
        layer : :class:`napari.layers.Labels`
            The newly-created labels layer.
        """
        layer = layers.Labels(
            data,
            is_pyramid=is_pyramid,
            num_colors=num_colors,
            seed=seed,
            n_dimensional=n_dimensional,
            name=name,
            metadata=metadata,
            scale=scale,
            translate=translate,
            opacity=opacity,
            blending=blending,
            visible=visible,
        )
        self.add_layer(layer)
        return layer
github napari / napari / benchmarks / benchmark_labels_layer.py View on Github external
def time_create_layer(self, n):
        """Time to create layer."""
        Labels(self.data)
github napari / napari / benchmarks / benchmark_labels_layer.py View on Github external
def setup(self, n):
        np.random.seed(0)
        self.data = np.random.randint(20, size=(n, n, n))
        self.layer = Labels(self.data)