我收到了这个警告,但我无法修复它。代码可以工作。
Warning: Lossy conversion from float64 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning.
from skimage.io import imread, imshow, imsave
img_grey = imread('C:/Lawn.png', as_gray=True)
imsave('Lawn22.png', img_grey)
img = imread('C:/Lawn.png')
imshow(img)发布于 2021-09-11 07:14:43
阅读图片转换float64 to type uint8后,您需要使用下面的代码删除此警告消息:
img_grey = img_grey / img_grey.max() #normalizes img_grey in range 0 - 255
img_grey = 255 * img_grey
img_grey = img_grey.astype(np.uint8)没有警告消息的完整代码:
from skimage.io import imread, imshow, imsave
img_grey = imread('C:/Lawn.png', as_gray=True)
# convert image to uint8
img_grey = img_grey / img_grey.max() #normalizes img_grey in range 0 - 255
img_grey = 255 * img_grey
img_grey = img_grey.astype(np.uint8)
imsave('Lawn22.png', img_grey)
img = imread('C:/Lawn.png')
imshow(img_grey)https://stackoverflow.com/questions/69140707
复制相似问题