Invert colors when plotting a PNG file using matplotlib

后端 未结 4 1976
-上瘾入骨i
-上瘾入骨i 2021-01-12 19:33

I\'m trying to display a PNG file using matplotlib and of course, python. For this test, I\'ve generated the following image:

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 20:19

    Color image loaded by OpenCV is in BGR mode. However, Matplotlib displays in RGB mode. So we need to convert the image from BGR to RGB:

    plt.imshow(cv2.cvtColor(cube, cv2.COLOR_BGR2RGB))
    

提交回复
热议问题