我正在尝试保存已处理的图像(作为原始图像启动,希望将其保存回Raw/dng/nef) 在某些像素超过阈值的情况下,给定的ndarray仅为-1,0,1
我很难理解这里的问题是什么:
imageio.imsave('images/imagesTest', image.Red.ZthreshMap)
鉴于此,我返回了此错误:
File "C:\Users\E\--\PycharmProjects\lib\site-packages\imageio\core\functions.py", line 303, in imwrite
writer = get_writer(uri, format, "i", **kwargs)
File "C:\Users\E\--\PycharmProjects\lib\site-packages\imageio\core\functions.py", line 227, in get_writer
"Could not find a format to write the specified file in %s mode" % modename
ValueError: Could not find a format to write the specified file in single-image mode
我已确认,以防为函数提供正确的数据类型:
<class 'numpy.ndarray'>
是什么类型,因此应该工作正常
因此,我尝试了以下方法,指定文件类型:
imageio.imsave('images/imagesTest.dng', image.Red.ZthreshMap, '.dng')
File "C:\Users\E\--\PycharmProjects\lib\site-packages\imageio\plugins\freeimage.py", line 127, in _append_data
self._bm.allocate(im)
File "C:\Users\E\--\PycharmProjects\lib\site-packages\imageio\plugins\_freeimage.py", line 825, in allocate
raise ValueError("Cannot write arrays of given type and shape.")
ValueError: Cannot write arrays of given type and shape.
这很奇怪,因为我仔细检查了形状和:
print(image.Red.ZthreshMap.shape)
最终导致(14342160)
有什么建议吗
如果你能更好地说明你想做什么,那么帮助你就会更容易。你为什么要“无压缩拍摄”?如果您的文件纯粹由值
-1
、0
和1
组成,那么它应该能够很好地无损压缩,这无疑是有利的目前,可能存在两个问题:
您尚未指定文件扩展名,因此
imageio
不知道是否要保存PNG、TIFF或JPEG有些值是
-1
,很少有图像格式可以保存负数,因为它们通常会记录黑色以上的亮度,因此负数比黑色更暗,如果不这样做,图像格式就不会为负数留出宝贵的空间相关问题 更多 >
编程相关推荐