When AI draws pixel art but forgets the grid
Perfect Pixel automatically detects the hidden grid in AI-generated pixel-style images and snaps them to clean, quantized squares.

What it does
AI image generators are prolific but sloppy pixel artists: they output images that look blocky yet sit on distorted, non-square grids with inconsistent cell sizes. Perfect Pixel ingests these faux-pixel images, recovers the actual underlying lattice dimensions, aligns the grid to real content edges, and resamples everything into honest, uniform squares. You get back a properly quantized image and its exact grid dimensions.
The interesting bit
Instead of asking you to count blocks manually, the tool treats grid detection as a signal-processing problem. It analyzes the image’s FFT magnitude spectrum to estimate the repeating pattern, then uses Sobel edge detection to nudge those grid lines into place. It is essentially a computer-vision spellchecker for AI pixel art.
Key highlights
- Auto-detects grid dimensions via frequency-domain analysis rather than metadata or guesswork.
- Refines estimated grid lines against Sobel edges to correct the subtle warping common in generated images.
- Offers both an OpenCV backend and a pure-NumPy backend for environments where OpenCV is unwelcome.
- Supports multiple sampling strategies—
center,median, andmajority—for reconstructing the final color of each cell. - Provides a ComfyUI node for dropping directly into Stable Diffusion workflows.
Caveats
- The tool expects an input that is already pixel-style and roughly 512–1024 pixels; it will not turn a smooth photograph into pixel art.
- The README does not characterize failure modes for heavily anti-aliased or non-grid-like inputs, so robustness on messy outliers is unclear.
Verdict
Grab this if you are feeding ChatGPT or Stable Diffusion output into game sprites, perler-bead patterns, or any workflow that demands a mathematically clean grid. If you are drawing pixel art by hand on a known canvas, you are already done.
Frequently asked
- What is theamusing/perfectPixel?
- Perfect Pixel automatically detects the hidden grid in AI-generated pixel-style images and snaps them to clean, quantized squares.
- Is perfectPixel open source?
- Yes — theamusing/perfectPixel is an open-source project tracked on heatdrop.
- What language is perfectPixel written in?
- theamusing/perfectPixel is primarily written in Python.
- How popular is perfectPixel?
- theamusing/perfectPixel has 1.6k stars on GitHub.
- Where can I find perfectPixel?
- theamusing/perfectPixel is on GitHub at https://github.com/theamusing/perfectPixel.