This project implements image processing using Lenia cellular automata with a Flask backend for intelligent image compression.
- Lenia-Enhanced Compression: Uses cellular automata patterns for predictive image compression
- Real Compression: Achieves 2:1 to 4:1 compression ratios with maintained quality
- Multi-format Support: Handles PNG, JPG, and JPEG images
- Color Preservation: Maintains color information in compressed images
- Web Interface: Simple drag-and-drop interface for image processing
- Python 3.7+
- Flask
- OpenCV (cv2)
- NumPy
- SciPy
- scikit-learn
-
Clone this repository
git clone <repository-url> cd <repository-name>
-
Create and activate a virtual environment:
python -m venv venv venv\Scripts\activate
-
Install dependencies:
pip install flask flask-cors opencv-python numpy scipy scikit-learn werkzeug
-
Run the Flask app:
python main.py
-
Open the web interface:
- Open
index.htmlin your web browser - Or navigate to
http://127.0.0.1:5000if serving the HTML through Flask
- Open
-
Clone this repository
git clone <repository-url> cd <repository-name>
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install flask flask-cors opencv-python numpy scipy scikit-learn werkzeug
-
Run the Flask app:
python3 main.py
-
Open the web interface:
- Open
index.htmlin your web browser - Or navigate to
http://127.0.0.1:5000if serving the HTML through Flask
- Open
- Upload an Image: Click "Choose File" and select a PNG, JPG, or JPEG image
- View Compression: The system will show:
- Original file size
- Compressed file size
- Compression ratio achieved
- Download Result: Click "Download Processed" to get the compressed image
- File Management: Previously uploaded files are stored locally and can be re-downloaded
The system uses Lenia Cellular Automata for intelligent image compression:
- Predictive Analysis: Lenia kernels analyze image patterns to predict pixel values
- Multi-scale Processing: Different kernel sizes handle various image features
- Residual Encoding: Only unpredictable differences are stored
- Smart Reconstruction: Combines Lenia predictions with stored residuals
- Quality Enhancement: Applies bilateral filtering for final image improvement
├── main.py # Flask backend server
├── index.html # Web interface
├── script.js # Frontend JavaScript
├── uploads/ # Temporary upload folder (auto-created)
├── processed/ # Compressed images storage (auto-created)
└── README.md # This file
POST /upload- Upload and compress an imageGET /download/<filename>- Download compressed imageGET /info/<filename>- Get compression information
"Module not found" errors:
pip install --upgrade pip
pip install flask flask-cors opencv-python numpy scipy scikit-learn werkzeugCORS errors in browser:
- Make sure Flask server is running on
http://127.0.0.1:5000 - Check that CORS is enabled in the Flask app
File upload fails:
- Ensure the image format is PNG, JPG, or JPEG
- Check file size (very large images may take longer to process)
Windows-specific issues:
- Use
pythoninstead ofpython3in commands - Use
venv\Scripts\activateto activate virtual environment - Ensure Python is added to system PATH
This project is open source and available under the MIT License.
- Lenia cellular automata research by Bert Wang-Chak Chan
- OpenCV for image processing capabilities
- Flask for the web framework