KennethJAllen/proper-pixel-art

Fixes AI pixel art images, video, or sprite web uploads

What it solves

Many generative AI models (like GPT-4o) or low-quality web uploads produce "pixel art" that is actually high-resolution and noisy, with non-uniform grids and artifacts. Standard downsampling fails to clean these images because they aren't perfectly aligned to a grid. This tool automates the recovery of clean, true-resolution pixel art assets from these noisy sources.

How it works

The tool uses a computer vision pipeline to reconstruct a pixel grid from a noisy image:

  1. Preprocessing: Trims edges and handles transparency issues.
  2. Edge Detection: Uses Canny edge detection and morphological closing to find the boundaries of the "pixels."
  3. Grid Reconstruction: Employs a probabilistic Hough transform to identify vertical and horizontal lines, clusters them, and calculates the median spacing to build a consistent mesh.
  4. Color Quantization: Reduces the image to a specific number of colors.
  5. Final Sampling: For each cell in the reconstructed mesh, it selects the most common color to create a single-pixel representation.

Who it’s for

  • Game Developers: To clean up AI-generated assets or low-quality screenshots for use in games.
  • Digital Artists: To convert high-res "pixel-style" images into actual pixel art.
  • AI Users: To transform outputs from generative models into usable, professional-grade assets.

Highlights

  • Animation Support: Works with videos and GIFs, computing a consistent mesh and palette across frames to prevent flickering.
  • Multiple Interfaces: Available as a CLI, a Python API, and a web interface (via Hugging Face Spaces).
  • Customizable: Supports YAML configuration files for fine-tuning edge detection and color quantization parameters.
  • Robot-like Precision: Automates a process that otherwise requires manual redrawing pixel-by-pixel.