如何根据numpy中的线性函数更改数组中的元素

时间:2021-10-04 21:22:22

I'm trying to convert 16 bit int raw TIFF to 8 bit int png. A step in that includes changing the values in an array from 0 - 4095 to 0 - 255.

我正在尝试将16位int原始TIFF转换为8位int png。其中的一步包括将数组中的值从0 - 4095更改为0 - 255。

example:

[0, 32, 64, ..., 4095] should be converted to: [0, 2, 4, ..., 255 ]

I know that this can be achieved with simple loop through all values in the array, but does numpy provide some standard function for this type of task? Thank you.

我知道这可以通过简单循环遍历数组中的所有值来实现,但numpy是否为这类任务提供了一些标准函数?谢谢。

1 个解决方案

#1


1  

simply multiplying the array (image) by float(255)/4095.0 won't do the trick?

简单地将数组(图像)乘以浮点数(255)/4095.0将无法实现?

#1


1  

simply multiplying the array (image) by float(255)/4095.0 won't do the trick?

简单地将数组(图像)乘以浮点数(255)/4095.0将无法实现?