【发布时间】:2018-06-07 06:01:25
【问题描述】:
我通过这个命令将一个 RGB 图像转换为lab:
im_lab=skimage.color.rgb2lab(im, illuminant='D65', observer='2')
但是,一旦我发送到我的算法进行分段然后通过matplotlib.pyplot 显示,我收到以下错误(这是一个很长的错误,但这是最后一部分):
/home/xxx/anaconda2/envs/lda-nv/lib/python2.7/site-packages/matplotlib/cm.pyc in to_rgba(self, x, alpha, bytes, norm)
255 if xx.dtype.kind == 'f':
256 if norm and xx.max() > 1 or xx.min() < 0:
--> 257 raise ValueError("Floating point image RGB values "
258 "must be in the 0..1 range.")
259 if bytes:
ValueError: Floating point image RGB values must be in the 0..1 range.
<matplotlib.figure.Figure at 0x7f14e4dfa990>
这是调用matplotlib的代码部分:
# displaying the result
fig = plt.figure()
a = fig.add_subplot(1, 2, 1)
plt.imshow(in_image)
a.set_title('Original Image')
a = fig.add_subplot(1, 2, 2)
print(output.shape)
plt.imshow(skimage.color.lab2rgb(output,illuminant='D65', observer='2'))
a.set_title('Segmented Image')
plt.show()
谁能帮我看看是什么原因,我该如何解决?
谢谢
【问题讨论】:
-
在绘图之前将其转换回 RGB(A)...这就是 pyplot 所期望的。
-
我通过 skimage 转换了,但是我仍然收到错误,这就是我在这里发布的原因。感谢您的评论
-
你能把
lab2rgb的形状、最小值、最大值和dtype的输出贴出来吗?
标签: python python-2.7 matplotlib anaconda scikit-image