|
5 | 5 | In the future, will add optional segmentation mesh overlay.
|
6 | 6 | """
|
7 | 7 |
|
8 |
| -from . import cm |
9 | 8 | import colorcet
|
10 | 9 | import matplotlib
|
11 | 10 | import collections
|
|
17 | 16 | import ipywidgets as widgets
|
18 | 17 | from traitlets import CBool, CFloat, CInt, Unicode, CaselessStrEnum, List, validate, TraitError, Tuple
|
19 | 18 | from ipydatawidgets import NDArray, array_serialization, shape_constraints
|
20 |
| -from .trait_types import ITKImage, ImagePointTrait, ImagePoint, PointSetList, PolyDataList, itkimage_serialization, image_point_serialization, polydata_list_serialization, Colormap |
| 19 | +from .trait_types import ITKImage, ImagePointTrait, ImagePoint, PointSetList, PolyDataList, itkimage_serialization, image_point_serialization, polydata_list_serialization, Colormap, LookupTable |
21 | 20 |
|
22 | 21 | try:
|
23 | 22 | import ipywebrtc
|
@@ -167,6 +166,12 @@ class Viewer(ViewerParent):
|
167 | 166 | help="RGB triples from 0.0 to 1.0 that define a custom linear, sequential colormap")\
|
168 | 167 | .tag(sync=True, **array_serialization)\
|
169 | 168 | .valid(shape_constraints(None, 3))
|
| 169 | + lut = LookupTable('glasbey', |
| 170 | + help='Lookup table for the label map.').tag(sync=True) |
| 171 | + _custom_cmap = NDArray(dtype=np.float32, default_value=None, allow_none=True, |
| 172 | + help="RGB triples from 0.0 to 1.0 that define a custom linear, sequential colormap")\ |
| 173 | + .tag(sync=True, **array_serialization)\ |
| 174 | + .valid(shape_constraints(None, 3)) |
170 | 175 | shadow = CBool(
|
171 | 176 | default_value=True,
|
172 | 177 | help="Use shadowing in the volume rendering.").tag(sync=True)
|
@@ -752,6 +757,7 @@ def view(image=None, # noqa: C901
|
752 | 757 | label_map_weights=None, # noqa: C901
|
753 | 758 | label_map_blend=0.5,
|
754 | 759 | cmap=None,
|
| 760 | + lut='glasbey', |
755 | 761 | select_roi=False,
|
756 | 762 | interpolation=True,
|
757 | 763 | gradient_opacity=0.22, opacity_gaussians=None, channels=None,
|
@@ -843,12 +849,20 @@ def view(image=None, # noqa: C901
|
843 | 849 | Value that maps to the minimum of image colormap. A single value can
|
844 | 850 | be provided or a list for multi-component images.
|
845 | 851 |
|
846 |
| - cmap: list of strings |
| 852 | + cmap: list of colormaps |
847 | 853 | default:
|
848 | 854 | - single component: 'viridis', 'grayscale' with a label map,
|
849 | 855 | - two components: 'BkCy', 'BkMa'
|
850 | 856 | - three components: 'BkRd', 'BkGn', 'BkBu'
|
851 |
| - Colormap for each image component. Some valid values available at itkwidgets.cm.* |
| 857 | + Colormap for each image component. Some valid values available at |
| 858 | + itkwidgets.cm.* |
| 859 | + Colormaps can also be Nx3 float NumPy arrays from 0.0 to 1.0 for the |
| 860 | + red, green, blue points on the map or a |
| 861 | + matplotlib.colors.LinearSegmentedColormap. |
| 862 | +
|
| 863 | + lut: lookup table, default: 'glasbey' |
| 864 | + Lookup table for the label map. Some valid values available at |
| 865 | + itkwidgets.lut.* |
852 | 866 |
|
853 | 867 | select_roi: bool, default: False
|
854 | 868 | Enable an interactive region of interest widget for the image.
|
@@ -1017,6 +1031,7 @@ def view(image=None, # noqa: C901
|
1017 | 1031 | label_map_names=label_map_names,
|
1018 | 1032 | label_map_weights=label_map_weights,
|
1019 | 1033 | cmap=cmap,
|
| 1034 | + lut=lut, |
1020 | 1035 | select_roi=select_roi,
|
1021 | 1036 | interpolation=interpolation,
|
1022 | 1037 | gradient_opacity=gradient_opacity, slicing_planes=slicing_planes,
|
|
0 commit comments