A Python-based tool that converts any input image into stunning low-poly art using computational geometry and advanced image processing techniques.
Poly Art Generator is a geometry-driven image processor that transforms standard images into stylized polygon meshes. Perfect for digital art, posters, NFTs, and creative coding projects. Unlike simple filters, this tool uses real computational geometry to create authentic low-poly artwork.
- π― Geometry-Driven Processing - Uses Delaunay triangulation, not basic filters
- π¨ Customizable Polygon Density - Control the level of detail in your artwork
- β‘ Lightweight & Offline - No internet connection required
- π§ Extensible Architecture - Easy to modify and enhance
- π¦ Production Ready - Clean code with modular design
# Clone the repository
git clone https://github.com/your-username/poly-art-generator.git
# Navigate to project directory
cd poly-art-generator
# Install dependencies
pip install -r requirements.txtopencv-python>=4.5.0
numpy>=1.19.0
scipy>=1.5.0
Pillow>=8.0.0
matplotlib>=3.3.0from poly_art import PolyArtGenerator
# Initialize the generator
generator = PolyArtGenerator()
# Convert your image
generator.generate(
input_path="input/photo.jpg",
output_path="output/poly_art.jpg",
num_points=500 # Adjust for polygon density
)poly-art-generator/
β
βββ poly_art.py # Main generator script
βββ requirements.txt # Project dependencies
βββ README.md # Documentation
β
βββ input/ # Place your input images here
β βββ sample.jpg
β
βββ output/ # Generated artwork saves here
β βββ result.jpg
β
βββ examples/ # Sample outputs & demos
βββ landscape.jpg
βββ portrait.jpg
# Simple conversion with default settings
python poly_art.py --input input/photo.jpg --output output/result.jpg# Fine-tune polygon density
python poly_art.py \
--input input/photo.jpg \
--output output/result.jpg \
--points 1000 \
--quality high# Process multiple images
python poly_art.py --batch --input-dir input/ --output-dir output/| Original Image | Low-Poly Art (500 points) | Low-Poly Art (1000 points) |
| Your before image here | Your after image here (low density) | Your after image here (high density) |
| Parameter | Type | Default | Description |
|---|---|---|---|
num_points |
int | 500 | Number of sampling points (controls polygon density) |
quality |
str | 'medium' | Output quality: 'low', 'medium', 'high' |
max_size |
int | 1920 | Maximum dimension for processing |
edge_detection |
bool | True | Enable edge-aware point sampling |
The generator uses intelligent point sampling that focuses on:
- Image edges and high-contrast regions
- Uniform distribution across flat areas
- Corner preservation for structural integrity
Employs SciPy's spatial Delaunay implementation for:
- Optimal triangle mesh generation
- No overlapping polygons
- Mathematically sound geometry
Each triangle color is computed using:
- Mean RGB values within triangle bounds
- Optional weighted averaging based on pixel importance
- Anti-aliasing for smooth color transitions
- Speed: Processes 1920Γ1080 images in ~2-5 seconds
- Memory: Peak usage ~200MB for high-resolution images
- Scalability: Handles images up to 4K resolution
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Add GUI interface
- Implement color palette customization
- Support for video processing
- Export to SVG format
- Real-time preview mode
- GPU acceleration with CUDA
- Very high polygon counts (5000+) may cause performance issues
- Transparent PNGs are converted to RGB format
- Some EXIF metadata is not preserved
- Delaunay triangulation algorithm by SciPy
- OpenCV community for image processing tools
- Inspiration from low-poly art movement
β‘ "Art is not what you see, but what you make others see." - Edgar Degas
Made by Aryan Ranjan | Star β this repo if you found it helpful!