【问题标题】:Python - How to read a set of images and put it in a matrix? [closed]Python - 如何读取一组图像并将其放入矩阵中? [关闭]
【发布时间】:2013-03-27 05:55:38
【问题描述】:

我需要使用 python 读取一组图像并将其放入矩阵中,以便能够执行 PCA(原理成分分析)。所有图像都在一个文件夹中。

【问题讨论】:

    标签: python image-processing face-recognition pca


    【解决方案1】:

    使用numpyPIL

    import numpy as np
    import Image
    
    dirname = '...'
    [np.asarray(Image.open(os.path.join(dirname, fn))) for fn in os.listdir(dirname)]
    

    【讨论】:

    • NameError: name 'np' is not defined
    • 它给出了这个错误 NameError: name 'np' is not defined
    • 抱歉我的许多问题,因为我是 python 新手,它给了我这个错误
    • IOError: [Errno 2] 没有这样的文件或目录:'10.pgm'
    • @user2229953:清理了我的代码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-08
    • 2020-03-16
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多