在skimage中将rgb转换为实验室语法错误

时间:2015-07-24 16:42:19

标签: python

我将3元组rgb值传递给skimage函数rgb2lab(http://scikit-image.org/docs/stable/api/skimage.color.html#rgb2lab

我一直收到这个ValueError:the input array must be have a shape == (.., ..,[ ..,] 3))

这种形状是什么样的?它不仅仅是一个三元组,例如(203, 198, 195)

1 个答案:

答案 0 :(得分:0)

该功能要求您以rgb格式传递图像,而不是单一颜色。数组的形状几乎就是尺寸ref

>>> x = np.array([1, 2, 3, 4])
>>> x.shape
(4,)
>>> y = np.zeros((2, 3, 4))
>>> y.shape
(2, 3, 4)
>>> y.shape = (3, 8)
>>> y
array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])
>>> y.shape = (3, 6)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: total size of new array must be unchanged

传入包含一些任意颜色值的单个元组将不会做太多,您需要做的是传递rgb 格式的图像

相关问题