Skip to content

Commit 4dcff8c

Browse files
committed
ENH: Default cmap with label_map for intensity image is grayscale
1 parent f61da9c commit 4dcff8c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

itkwidgets/widget_viewer.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,15 @@ def __init__(self, **kwargs): # noqa: C901
312312
opacities_array = self._validate_geometry_opacities(proposal)
313313
kwargs['geometry_opacities'] = opacities_array
314314
self.observe(self._on_geometries_changed, ['geometries'])
315-
if 'label_map' in kwargs:
315+
have_label_map = 'label_map' in kwargs and kwargs['label_map'] is not None
316+
if have_label_map:
316317
# Interpolation is not currently supported with label maps
317318
kwargs['interpolation'] = False
319+
if not 'cmap' in kwargs or kwargs['cmap'] is None:
320+
if have_label_map:
321+
kwargs['cmap'] = cm.grayscale
322+
else:
323+
kwargs['cmap'] = cm.viridis
318324

319325
super(Viewer, self).__init__(**kwargs)
320326

@@ -643,7 +649,7 @@ def roi_slice(self):
643649

644650
def view(image=None, # noqa: C901
645651
label_map=None, # noqa: C901
646-
cmap=cm.viridis,
652+
cmap=None,
647653
select_roi=False,
648654
interpolation=True,
649655
gradient_opacity=0.22, slicing_planes=False, shadow=True, blend='composite',
@@ -722,7 +728,7 @@ def view(image=None, # noqa: C901
722728
Value that maps to the minimum of image colormap. Defaults to maximum of
723729
the image pixel buffer.
724730
725-
cmap: string, optional, default: 'Viridis (matplotlib)'
731+
cmap: string, optional, default: viridis, grayscale with a label map
726732
Colormap. Some valid values available at itkwidgets.cm.*
727733
728734
select_roi: bool, optional, default: False

0 commit comments

Comments
 (0)