【问题标题】:After converting from rgb to lab it is raising issue by matplotlib?从 rgb 转换为 lab 后,matplotlib 会引发问题吗?
【发布时间】: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


【解决方案1】:

根据我发现here 的帖子,似乎在分割后你得到了像这样弹出的负值作为问题。

上面贴出来的解决方案好像是

Value<0 equate the value to 0

解决方案似乎有效,如果它对您也有帮助,请查看上面的链接

【讨论】:

    猜你喜欢
    • 2021-10-18
    • 2012-11-04
    • 1970-01-01
    • 2023-02-14
    • 2018-02-25
    • 2021-08-24
    • 2011-06-03
    • 1970-01-01
    • 2014-02-08
    相关资源
    最近更新 更多