标签: python arrays numpy
我试图将16位int原始TIFF转换为8位int png。 其中一步包括将数组中的值从0 - 4095更改为0 - 255。
示例:
[0, 32, 64, ..., 4095] should be converted to: [0, 2, 4, ..., 255 ]
我知道这可以通过简单循环遍历数组中的所有值来实现,但是numpy是否为这类任务提供了一些标准函数?谢谢。
答案 0 :(得分:1)
只需将数组(图片)乘以float(255)/4095.0即可获得诀窍?
float(255)/4095.0