Skip to content

mmitzy/PokemonTCG-Gen

Repository files navigation

PokemonTCG-Gen

🌟 Pokémon TCG Collage Generator

A high-resolution collage generator using thousands of Pokémon TCG cards.

Pokémon TCG Collage Generator Banner

📑 Table of Contents

Overview 🧩

This project generates ultra-high-resolution image mosaics using Pokémon TCG card art. It loads an input image, splits it into blocks, and finds the closest matching Pokémon card for each block using LAB color distance, HSV weighting, saturation awareness, and optional rotation/displacement.

Outputs can reach 7000×7000 or more and are suitable for large prints and posters.

Project Structure 📁

PokemonTCG-Gen/
│
├── populate-pokemon-db.py
├── preprocess-color-pokemon-db.py
├── aggregate-pokemon-images.py
│
├── Pokemon Mosaics - Database/
├── images/
├── input_test/
└── output_test/

Requirements ✅

  • Python 3.10+

  • MySQL 8+

  • OpenCV

  • NumPy

  • TiffFile

  • MySQL Connector

  • Pillow

  • ColorMath

Installation 🛠

  • Clone
git clone https://github.com/mmitzy/PokemonTCG-Gen.git
cd PokemonTCG-Gen
  • Create venv
python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt

Dataset Download & Setup 📥

Run:

python populate-pokemon-db.py

Creates all tables + downloads all official Pokémon TCG images + fills DB.

Color Preprocessing 🎨

Run:

python preprocess-color-pokemon-db.py

This computes average/median colors in RGB, HSV, LAB and stores them in MySQL.

Generating The Collage 🧱

Example (7K resolution):

python aggregate-pokemon-images.py input_test --algorithm collage --size 7000x7000 --timeout 9999 --output output_test/final.png --config "width=20,height=20,candidates=2000,prefilter=30,tolerance=8,saturation=0.4"

Available Algorithms 🧠

-collage: The main Pokémon mosaic engine -average: Pixel averages -median: Pixel medians -average_row: Row collapsing -average_square: Block averages -similarity_heatmap: Card similarity map -compose_columns: Column-stacked composition -test: Debug mode

Collage Algorithm Parameters

--config "width=20,height=20,candidates=2000,prefilter=30,tolerance=8,saturation=0.4,rotation=15,displacement=1"

Parameter meanings:

-width,height: Tile size -candidates: SQL candidate depth -prefilter: LAB quick filter -tolerance: Max CIEDE2000 distance -saturation: Weight for color saturation -rotation: Random angle per tile -displacement: Pixel jitter -repeat: Allow card reuse

TIFF Support 🖼

TIFF is recommended for huge outputs (≥4000×4000):

✔ Supports massive resolutions ✔ Lossless ✔ Photoshop/GIMP compatible ✔ deflate and lzw compression supported

Example:

--output output_test/final.tiff --compression deflate

Images 📸

UNFINISHED, IMAGES ARE SOON TO BE ADDED

  1. Fast Test – 512×512 Input Output
  2. Medium – 2048×2048

3. High – 4096×4096

4. Ultra High – 7000×7000

5. Sky Correction Before After

Performance Notes 🚀

Large collages (7000×7000) can take 8-24 hours

Use --timeout 9999 to avoid automatic termination

Avoid system sleep mode

Increase candidates, prefilter, saturation for better color fidelity

Troubleshooting 🩹

❗ No candidates found

Increase:

prefilter=40
candidates=2500
tolerance=10

❗ Sky turns red

Use:

saturation=0.4 or 0.5
prefilter=30+

❗ Script stops

Add:

--timeout 9999

About

A model that turns any image input into a Pokemon TCG pixel-art!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published