【发布时间】:2017-11-29 15:40:47
【问题描述】:
我正在使用 sci-kits 模块 skimage 将图像从 RGB 颜色空间转换为 LAB 并再次转换回来。我从这个问题中找到了以下函数:Convert an image RGB->Lab with python,但这并没有解决如何将图像还原为静态。
代码:
file = 'C://Users/Alec/Pictures/25 zone test.png'
pix = numpy.array(PIL.Image.open(file))
print(pix[0,0])
pix = color.rgb2lab(pix)
print(pix[0,0])
pix = color.lab2rgb(pix)
print(pix[0,0])
pix *= 255
print(pix[0,0])
pix = pix.astype(int)
print(pix[0,0])
pic = PIL.Image.fromarray(pix, 'RGB')
pic.show()
输出:
[255 255 255]
[ 1.00000000e+02 -2.45493786e-03 4.65342115e-03]
[ 1. 1. 1.]
[ 255. 255. 255.]
[255 254 254]
print 语句的输出似乎或多或少是合适的,但是生成的图像肯定不是。
有没有我遗漏的步骤才能正常工作?
原图:
结果:
【问题讨论】:
-
你在做一些奇怪的事情,比如乘以 255,然后在下一行覆盖它
标签: python scikit-image