我有一个像
result = np.array([[[289, 354, 331],
[291, 206, 66],
[242, 70, 256]],
[[210, 389, 342],
[273, 454, 218],
[255, 87, 256]],
[[127, 342, 173],
[450, 395, 147],
[223, 228, 401]]])
Run Code Online (Sandbox Code Playgroud)
如果一个元素大于 255,我试图屏蔽数组。即我假设它的范围是 0-1024 并将我的值除以 4
result = np.putmask(result, result > 255, result/4)
Run Code Online (Sandbox Code Playgroud)
注意:结果是之前的 3D 数组。我收到此错误
TypeError: Cannot cast array data from dtype('float64') to dtype('int32') according to the rule 'safe'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?提前致谢