【问题标题】:Converting gray scale image to 3 dimensional tensor (N, N, 1) with Pillow使用 Pillow 将灰度图像转换为 3 维张量 (N, N, 1)
【发布时间】:2021-07-28 22:11:03
【问题描述】:

我正在尝试使用灰度图像输入来制作 YOLO 架构。 一般来说,YOLO 的输入是 RGB 图像(3-dim 张量),其大小为 (N, N, 3),其中 N 是图像的大小,3 代表 R、G 和 B 通道。 当用枕头阅读图像时,下面的代码给了我 2-dim 张量图像。即 (N , N)。

from PIL import Image
image = Image.open('sample.jpg')
image = image.convert('L')

但是,为了将这张图片作为 YOLO 架构的输入,我需要它的大小为 (N, N, 1) ,其中 1 表示灰色通道。是 3-dim 张量。

如果可能的话,如果解决方案是在代码中使用枕头给出的,我会很高兴。

【问题讨论】:

    标签: python machine-learning image-processing computer-vision python-imaging-library


    【解决方案1】:

    我发现在 Pillow 中,没有办法做我想做的事。因此,我决定使用 numpy。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 1970-01-01
      • 2021-04-05
      • 1970-01-01
      相关资源
      最近更新 更多