GitHub - theamusing/perfectPixel: Refine and quantize messy AI pixel art into clean, perfect pixels.
Key Points
- 1Perfect Pixel is an automated tool designed to rectify AI-generated pixel art by detecting optimal grid sizes and aligning distorted pixels into a clean, consistent format.
- 2The library offers both an OpenCV-based backend for high performance and a lightweight NumPy-only alternative to suit various technical environments.
- 3The core algorithm identifies grids using FFT magnitude, refines them through Sobel edge detection, and resamples the original image to produce a perfectly aligned, pixel-perfect output.
Perfect Pixel: Automated Grid Alignment for Pixel Art
Perfect Pixel is a specialized computational tool designed to resolve the common issues of inconsistent sizing and grid misalignment inherent in AI-generated pixel art. It automates the detection of optimal grid structures and refines distorted images to ensure they adhere to a perfect, pixel-aligned format. The tool offers two implementation backends—an OpenCV-based version for optimal performance and a lightweight, NumPy-only alternative.
Core Methodology
The algorithmic process of Perfect Pixel is structured into three primary technical phases:- Grid Size Detection via FFT:
- Edge Detection and Grid Refinement:
This ensures the grid snaps correctly to the center of the visual pixels.
- Image Sampling:
- Center: Samples the pixel value strictly from the center of each detected grid cell.
- Median: Calculates the median color value within the grid cell boundaries.
- Majority: Selects the most frequent color present in the grid cell, which is often the most robust method for noisy or distorted AI-generated inputs.