# image-pca **Repository Path**: williamzjc/image-pca ## Basic Information - **Project Name**: image-pca - **Description**: image pca (仅供毕业设计) - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-11-13 - **Last Updated**: 2021-01-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # image-pca PCA for image [PCA原理](/PCAcn.md) **仅供毕业设计!!!** ## 介绍 只是一个PCA wrapper (scikit-learn). fit 等方法的输入式图片列表而不是数组. 还可直接用 ezfit. 主程序:impca.py 辅助:PIL_ext.py(为扩展Pillow而写) ## 依赖 - numpy - scikit-learn - pillow - PIL_ext (written by the author) ## 使用 ```python # construct PCA model with 2 components ip = ImagePCA(n_components=2) # images = a list of image (based on pillow) ip.fit(images) # ip.ezfit(folder) # eazy version of fit method, folder is the folder of images # get and save eigen images for k, im in enumerate(ip.eigen_images): im.save(f'eigen{k}.jpg') # get coordinates and errors of images (that could be new) coords = ip.coordinate(images) errors = ip.error(images) # see demo function ``` ## 实验 ```python from impca import * demo(n_components=2) # 请设置图片文件夹路径 ``` 见两张图片 (eigen images) 和 .csv 文件. ![eigen 0](eigen0.jpg) ![eigen 1](eigen1.jpg)