diff --git a/package/PartSeg/common_gui/napari_image_view.py b/package/PartSeg/common_gui/napari_image_view.py index c2d001aec..826cfc709 100644 --- a/package/PartSeg/common_gui/napari_image_view.py +++ b/package/PartSeg/common_gui/napari_image_view.py @@ -15,7 +15,7 @@ from napari.layers.labels import Labels from napari.qt import QtViewer from napari.qt.threading import thread_worker -from napari.utils.colormaps.colormap import ColormapInterpolationMode +from napari.utils.colormaps.colormap import ColormapInterpolationMode, DirectLabelColormap from packaging.version import parse as parse_version from qtpy.QtCore import QEvent, QPoint, Qt, QTimer, Signal, Slot from qtpy.QtWidgets import QApplication, QCheckBox, QHBoxLayout, QLabel, QMenu, QSpinBox, QToolTip, QVBoxLayout, QWidget @@ -839,7 +839,7 @@ def _mark_layer(self, num: int, flash: bool, image_info: ImageInfo): component_mark, scale=image_info.roi.scale, blending="translucent", - colormap={0: (0, 0, 0, 0), 1: "white", None: (0, 0, 0, 0)}, + colormap=DirectLabelColormap(color_dict={0: (0, 0, 0, 0), 1: "white", None: (0, 0, 0, 0)}), opacity=0.7, ) self.viewer.layers.selection.active = active_layer diff --git a/package/PartSeg/plugins/napari_widgets/search_label_widget.py b/package/PartSeg/plugins/napari_widgets/search_label_widget.py index f46972d15..0d0932f5b 100644 --- a/package/PartSeg/plugins/napari_widgets/search_label_widget.py +++ b/package/PartSeg/plugins/napari_widgets/search_label_widget.py @@ -4,6 +4,7 @@ from magicgui.widgets import Container, HBox, PushButton, SpinBox, create_widget from napari import Viewer from napari.layers import Labels +from napari.utils import DirectLabelColormap from napari.utils.notifications import show_info from qtpy.QtCore import QTimer from vispy.geometry import Rect @@ -77,7 +78,7 @@ def _highlight(self): name=HIGHLIGHT_LABEL_NAME, scale=labels.scale, blending="translucent", - color={0: (0, 0, 0, 0), 1: "white"}, + colormap=DirectLabelColormap(color_dict={0: (0, 0, 0, 0), 1: "white", None: (0, 0, 0, 0)}), opacity=0.7, )