Skip to content

Mosaic Art GeneratorHigh-performance mosaic art generator written in Rust

Create stunning mosaic images by intelligently replacing sections of a target image with smaller material images based on perceptual color similarity.

Mosaic Art Generator

Quick Start ​

Transform any image into a detailed mosaic composed of thousands of smaller images:

bash
# Install dependencies
cargo build --release

# Basic usage
./target/release/mosaic-rust \
  --target photo.jpg \
  --material-src ./materials \
  --output mosaic.jpg

# High quality settings
./target/release/mosaic-rust \
  --target photo.jpg \
  --material-src ./materials \
  --output mosaic.jpg \
  --grid-w 100 --grid-h 75 \
  --max-materials 2000 \
  --adjacency-penalty-weight 0.25 \
  --color-adjustment-strength 0.4 \
  --optimization-iterations 2000

Example Output ​

Original Image

Original Image

Generated Mosaic

Generated Mosaic (24,000 tiles)

Why Choose Mosaic Art Generator? ​

πŸ”¬ Advanced Algorithms ​

  • Uses perceptually uniform Lab color space for accurate color matching
  • k-d tree data structure provides O(log n) search performance
  • Simulated annealing optimization for best tile placement

πŸš€ Performance Optimized ​

  • Parallel processing with Rayon for multi-core utilization
  • SIMD-optimized image resizing via fast_image_resize
  • Efficient memory usage with Arc<Tile> for shared immutable data

🎨 Professional Quality ​

  • Multi-factor scoring system considering color, usage, and adjacency
  • Advanced color adjustment using HSV transformations
  • Similarity database with JSON persistence for faster subsequent runs

πŸ› οΈ Developer Friendly ​

  • Comprehensive CLI with 20+ configuration options
  • Extensive test coverage (111+ tests)
  • Clean, modular architecture with 8 specialized modules

Key Features ​

FeatureDescription
Perceptual Color MatchingUses Lab color space with k-d tree for O(log n) nearest neighbor search
Smart PlacementMulti-factor scoring considering color distance, usage limits, and adjacency penalties
Parallel ProcessingAutomatic parallelization with Rayon for multi-core performance
Color AdjustmentHSV-based color adjustment for better matching with target regions
Optimization EngineSimulated annealing algorithm for iterative tile placement improvement
Real-time VisualizationASCII grid display and progress tracking with ETA
Similarity DatabasePre-computed similarity matrix with JSON persistence
Aspect Ratio MatchingIntelligent filtering with fallback strategies

Architecture Overview ​

The Mosaic Art Generator is built with a modular architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Material      β”‚    β”‚   Similarity    β”‚    β”‚   k-d Tree      β”‚
β”‚   Loading       │───▢│   Database      │───▢│   Indexing      β”‚
β”‚   (Parallel)    β”‚    β”‚   (Cached)      β”‚    β”‚   (O(log n))    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                       β”‚                       β”‚
          β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Grid          β”‚    β”‚   Tile          β”‚    β”‚   Color         β”‚
β”‚   Generation    │───▢│   Placement     │───▢│   Adjustment    β”‚
β”‚   (Target)      β”‚    β”‚   (Multi-       β”‚    β”‚   (HSV)         β”‚
β”‚                 β”‚    β”‚   factor)       β”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                       β”‚                       β”‚
          β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Optimization  β”‚    β”‚   Image         β”‚    β”‚   Final         β”‚
β”‚   (Simulated    │───▢│   Assembly      │───▢│   Mosaic        β”‚
β”‚   Annealing)    β”‚    β”‚   (Parallel)    β”‚    β”‚   Output        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Getting Started ​

Ready to create your first mosaic? Follow our comprehensive guide:

  1. Installation - Set up your development environment
  2. Quick Start - Run your first mosaic generation
  3. First Mosaic - Step-by-step tutorial
  4. CLI Reference - Complete parameter documentation

Community & Support ​

Project Statistics ​

πŸ“Š Code Quality

  • 111+ comprehensive tests
  • 81%+ code coverage
  • Zero clippy warnings
  • Formatted with rustfmt

⚑ Performance

  • O(log n) color search
  • Parallel processing
  • SIMD optimizations
  • Memory efficient

πŸ› οΈ Developer Experience

  • Comprehensive CLI
  • Real-time feedback
  • Extensive documentation
  • Clean architecture

🎨 Art Quality

  • Perceptual color matching
  • Smart tile placement
  • Color adjustment
  • Pattern optimization

Ready to create stunning mosaic art? Get Started β†’

Released under the MIT License.