【问题标题】:Import Multipage TIFF as separate images in Python在 Python 中将多页 TIFF 作为单独的图像导入
【发布时间】:2018-12-06 20:40:04
【问题描述】:

我目前正在 python 2 中进行一些图像处理。我将图像保存为多页 .tif 文件,其中包含 4 个分辨率为 1920x1080 的图像。我已经使用skimage.io.imread 导入了 tiff 文件。完成此操作后,我将得到一个形状为 (1080,1920,4) 的 ndarray。我应该如何将其分解为四个单独的 1920x1080 Numpy 数组,然后我可以将它们用于图像处理?

【问题讨论】:

    标签: python image-processing


    【解决方案1】:

    你可以使用numpy.dsplit():

    arrays = numpy.dsplit(a, a.shape[2])
    

    这将为您提供一个包含所需数组的列表。

    您可以选择只使用切片:

    arrays = [a[:,:,n] for n in range(a.shape[2])]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-14
      • 2020-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多