This project provides a Python script with a graphical user interface (GUI) for compressing images using Singular Value Decomposition (SVD). It allows users to select an input image, choose the desired output directory, and perform the compression operation, which results in various levels of compressed images and a plot of error versus compression ratio.
Before running this script, make sure the following Python packages are installed:
- NumPy
- Matplotlib
- PIL (Pillow)
- Tkinter (usually included by default in Python installations)
You can install the necessary packages using pip:
pip install numpy matplotlib pillow
To use the tool, follow these steps:
- Run the script via command line or an IDE.
- The GUI window will open.
- Click on "Browse Image" to select the image you want to compress. If you cannot find the image file in the selected folder, please make sure you select "All files" option.
- Click on "Browse Output Folder" to select the destination for the compressed images and additional generated files.
- Click on "Compress Image" to start the compression process.
After the compression is finished, you will see:
- Compressed versions of the original image at various compression levels.
- A plot image showing the error vs. compression ratio.
- A text file summarizing the compression errors and ratios.
The tool generates:
- A PNG image for each specified compression percentage with labels indicating the compression percentage.
- A PNG image showing a plot of error versus compression ratio.
- A text file (
error_compression_data.txt
) containing a list of each percentage with corresponding error and compression ratio.
These files will be saved in the selected output directory.
- GUI for easy interaction.
- Several levels of image compression based on different percentages of singular value retention.
- Calculation and visualization of error vs. compression ratio.
- Handling of PNG and JPEG image files for compression.