def sanitise_image(mat): int_mat = np.rint(mat).astype(int) return np.clip(int_mat, 0, 255).astype(np.uint8)