我正试着和Mahotas一起写一张图片,但我发现这很难。
img = mahotas.imread('foo.png', True)
mahotas.imsave('bar.png', img)我得到的错误是:
ValueError: mahotas.freeimage: cannot write arrays of given type and shape.我使用的是OS,使用brew安装了freeimage。
发布于 2012-01-18 22:36:24
mahotas的作者在这里。错误消息并不理想(将会修复它),但以下是发生的情况。
灰度图像是浮点图像(即img.dtype == numpy.float64),不能将浮点图像另存为PNG。
转换为numpy.uint8
mahotas.imsave('test.png', img.astype(numpy.uint8))它将会像预期的那样工作。
https://stackoverflow.com/questions/8888406
复制相似问题