个人笔记...

代码:

import matplotlib
import PIL
img1 = PIL.image.open('data/membrane/train/image/ID_0000_Z_0142.png')
img2 = matplotlib.image.imread('data/membrane/train/image/ID_0000_Z_0142.png')
plt.figure()
plt.subplot(1,2,1)
plt.imshow(img1)
plt.subplot(1,2,2)
plt.imshow(img2)
plt.show()

Python PIL.Image.open与 matplotlib.image.imread读取图片的区别

左边为PIL.image.open读入的png二值图片为四通道,matplotlib.image.imread为单通道。

 

img1 = Image.open('data/membrane/train/image/ID_0000_Z_0142.tif')
img2 = matplotlib.image.imread('data/membrane/train/image/ID_0000_Z_0142.tif')
plt.figure()
plt.subplot(1,2,1)
plt.imshow(img1)
plt.subplot(1,2,2)
plt.imshow(img2)
plt.show()

读取二值tif图像时,两种都默认为四通道。。。。

Python PIL.Image.open与 matplotlib.image.imread读取图片的区别

相关文章:

  • 2021-10-01
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-01-27
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2022-12-23
相关资源
相似解决方案