【问题标题】:how to get correct order of the image when converted to numpy array?转换为numpy数组时如何获得正确的图像顺序?
【发布时间】:2011-09-19 10:53:32
【问题描述】:

我正在从磁盘读取图像并将其转换为 numpy 数组

im=Image.open(infile)
imdata = scipy.misc.fromimage(im)

但是镜像是镜像的,就像它存储在磁盘上一样。

如何以正确的顺序阅读。

非常感谢。

【问题讨论】:

  • 你试过转置吗?

标签: python image numpy


【解决方案1】:

如果倒置:

imagedata = imagedata[::-1, :]

如果从左到右交换:

imagedata = imagedata[:, ::-1]

如果它被转置(在对角线上翻转):

imagedata = imagedata.T

如果您有更多维度(颜色、alpha、...),则可以通过

完成翻转
imagedata = imagedata[::-1, ... ]

imagedata = imagedata[:, ::-1, ... ]

“...”不是我不知道的东西的占位符,而是 numpy 中实现的功能。

【讨论】:

    猜你喜欢
    • 2018-05-31
    • 1970-01-01
    • 2021-01-05
    • 2019-12-29
    • 2018-07-21
    • 2023-03-17
    • 2010-09-27
    • 2011-12-07
    相关资源
    最近更新 更多