Debian Codegraph @

imgviz/dtype.py

raw symbols SCIP
1 import numpy as np
2
3
4 def bool2ubyte(img):
5 assert img.dtype == bool, "img dtype must be bool"
6 return img.astype(np.uint8) * 255
7
8
9 def float2ubyte(img):
10 assert np.issubdtype(img.dtype, float), "img dtype must be float"
11 assert img.min() >= 0, "img.min() must be >= 0"
12 assert img.max() <= 1, "img.max() must be <= 1"
13 return (img * 255).round().astype(np.uint8)