KennethJAllen/proper-pixel-art

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

What it solves

This tool converts noisy, high-resolution images that look like pixel art (often produced by generative AI models or low-quality web uploads) into clean, true-resolution pixel assets. It solves the problem where standard downsampling fails because these images often have non-uniform grids and random artifacts.

How it works

The tool uses a computer vision pipeline to recover the original pixel grid:

  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 Recovery: Employs a probabilistic Hough transform to identify horizontal and vertical lines, clusters them, and calculates the median spacing to establish a consistent mesh.
  4. Finalization: Quantizes the image colors and assigns the most common color in each mesh cell to a single pixel, recreating the image at its true resolution.

For videos and GIFs, the tool samples a few frames to determine a single shared grid and palette, ensuring the animation remains consistent without flickering.

Who it’s for

  • Game Developers: To clean up AI-generated assets or low-quality screenshots of pixel art.
  • Python Developers: Who want to integrate this recovery process into their own applications via a Python API.
  • Digital Artists: Who want to automate the recovery of pixel-perfect assets from noisy sources.

Highlights

  • Animation Support: Processes videos and GIFs while maintaining frame-to-frame consistency.
  • Flexible Interface: Available as a CLI, a Python API, and a web interface (hosted on Hugging Face Spaces).
  • Customizable: Supports YAML configuration files for fine-tuning edge detection and color quantization parameters.
  • Canny & Hough Transform: Uses established CV techniques to ensure robust grid detection even in adversarial examples.

Related

  • Project
  • Project
  • Project
  • Project
  • Project