def numpy_int16_to_uint8(depth): x, y = depth.shape out = np.ndarray((x, y, 2), dtype=np.uint8) out[:, :, 0] = np.right_shift(depth, 8) out[:, :, 1] = depth.astype(np.uint8) return out