Module iaf.io.cast
Data type casting utilities.
Functions
def safe_to_uint16(img: numpy.ndarray) ‑> numpy.ndarray
-
Casts the input array to
np.uint16
making sure to avoid overflows. No rescaling is applied.Parameters
img
:N-D array
- Two-dimensional, three-dimensional, or RGB(A) image of type
bool
,np.uint8
,np.float32
,np.float64
to convert tonp.uint16
.
Returns
out
:N-D array
- Same dimensionality of the input, but of type
np.uint16
.
def safe_to_uint8(img: numpy.ndarray) ‑> numpy.ndarray
-
Casts the input array to
np.uint8
making sure to avoid overflows. No rescaling is applied.Parameters
img
:N-D array
- Two-dimensional, three-dimensional, or RGB(A) image of type
bool
,np.uint16
,np.float32
,np.float64
to convert tonp.uint8
.
Returns
out
:N-D array
- Same dimensionality of the input, but of type
np.uint8
.