python - 在 Python 中处理 14 位数据

标签 python numpy bit

我当前的工作流程涉及处理以 16 位格式和 64 位格式编写的 8 位分辨率数据。例如:

b = np.fromfile(file, dtype='uint8')
data1 = b[:2].view(np.int16)
data2 = b[2:10].view(np.int64)
# alternative: struct.unpack 

我刚刚收到 14 位分辨率数据 - 什么是合适的类似方法来加载此数据,因为没有 14 位类型可用?


编辑: 在评论中回答 - 谢谢 honza_p。

将它们读取为 16 位并移动 2 位。

最佳答案

添加为答案以防评论消失。

Read them as 16-bit and shift 2 bits.

关于python - 在 Python 中处理 14 位数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38097286/

相关文章:

python - 针对一维列表绘制单行二维 numpy 数组

scala - 为什么 chisel UInt(32.W) 不能取 bit[32] 恰好为 1 的无符号数?

syntax - 学习位操作时的 "0xXXXX"语法是什么? (其中 X 是大写字母数字字符)

用于散热的 Python numpy 矢量化

Python重命名重复项

python - 在对 for 循环的结果进行排序时保持值连接

python - 如何使用增强来设置训练,同时确保未增强的实际图像也得到训练?

python - NumPy pcolormesh : TypeError: Dimensions of C are incompatible with X and/or Y

python - 我可以强制 numpy ndarray 获取其内存的所有权吗?

algorithm - 当我们处理非常大的数据时什么时候使用布隆过滤器以及什么时候使用位图?