iaf.io.cast

Data type casting utilities.

iaf.io.cast.safe_to_uint16(img: ndarray) ndarray[source]

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 to np.uint16.

Returns:

out – Same dimensionality of the input, but of type np.uint16.

Return type:

N-D array

iaf.io.cast.safe_to_uint8(img: ndarray) ndarray[source]

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 to np.uint8.

Returns:

out – Same dimensionality of the input, but of type np.uint8.

Return type:

N-D array