MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / get_label_rgb

Function get_label_rgb

monai/visualize/utils.py:210–216  ·  view source on GitHub ↗
(cmap: str, label: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

208 image = repeat(image, 3, axis=0)
209
210 def get_label_rgb(cmap: str, label: NdarrayOrTensor) -> NdarrayOrTensor:
211 _cmap = plt.colormaps.get_cmap(cmap)
212 label_np, *_ = convert_data_type(label, np.ndarray)
213 label_rgb_np = _cmap(label_np[0])
214 label_rgb_np = np.moveaxis(label_rgb_np, -1, 0)[:3]
215 label_rgb, *_ = convert_to_dst_type(label_rgb_np, label)
216 return label_rgb
217
218 label_rgb = get_label_rgb(cmap, label)
219 if isinstance(alpha, (torch.Tensor, np.ndarray)):

Callers 1

blend_imagesFunction · 0.85

Calls 2

convert_data_typeFunction · 0.90
convert_to_dst_typeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…