(error_map: np.ndarray, mask: np.ndarray = None, cmap: str = 'plasma', value_range: Tuple[float, float] = None)
| 56 | |
| 57 | |
| 58 | def colorize_error_map(error_map: np.ndarray, mask: np.ndarray = None, cmap: str = 'plasma', value_range: Tuple[float, float] = None): |
| 59 | vmin, vmax = value_range if value_range is not None else (np.nanmin(error_map), np.nanmax(error_map)) |
| 60 | cmap = matplotlib.colormaps[cmap] |
| 61 | colorized_error_map = cmap(((error_map - vmin) / (vmax - vmin)).clip(0, 1))[..., :3] |
| 62 | if mask is not None: |
| 63 | colorized_error_map = np.where(mask[..., None], colorized_error_map, 0) |
| 64 | colorized_error_map = np.ascontiguousarray((colorized_error_map.clip(0, 1) * 255).astype(np.uint8)) |
| 65 | return colorized_error_map |
nothing calls this directly
no outgoing calls
no test coverage detected