This project was created for Math22a: Vector Calculus and Linear Algebra, Fall2020. This accompanying repository includes an IPython Notebook and a CLI Tool to compress images of your choice. The annotated code containing the PCA algorithm can be found in compress.py
or pca_image_compression_test.ipynb
files.
To run the IPython Notebook, reference the docs here. The following instructions are for using the CLI Tool.
If you don't have pip
installed, please see here.
- Open a new terminal in the project directory and run
pip install -r requirements.txt
-
Place the original image in the
test_files
folder. -
To generate a new image from the principal components, run
python compress.py <filename> <number of components>
. The filename argument is just the filename, not the path in the directory (ex. to compresstest_files/cat.jpg
with100
components, runpython compress.py cat.jpg 100
).