【问题标题】:Image color changed after converting from numpy array to PIL image python从numpy数组转换为PIL图像python后图像颜色发生变化
【发布时间】:2017-06-22 07:58:39
【问题描述】:

我正在尝试将存储在 numpy 数组中的 cv2.imread 读取的图像转换为 PIL Image 对象,图像的颜色将被更改这是代码

I=cv2.imread("Image.jpg")
PILImage=Image.fromarray(I,mode='RGB')

如何取回我的原始图像?

【问题讨论】:

    标签: python python-imaging-library cv2


    【解决方案1】:

    OpenCV 喜欢将图像视为具有 BGR 层而不是 RGB 层。添加

    I = cv2.cvtColor(I, cv2.COLOR_BGR2RGB)
    

    会根据您的期望交换图层。

    【讨论】:

      猜你喜欢
      • 2020-03-14
      • 1970-01-01
      • 2022-08-21
      • 1970-01-01
      • 2017-06-25
      • 2012-06-13
      • 1970-01-01
      • 1970-01-01
      • 2010-09-27
      相关资源
      最近更新 更多