ComfyUI Node

Pixel Art Normalizer

Detect the pixel grid and true-up any image to clean pixel art

By marcoc2·Created 2 years ago·Updated 4 months ago· 1
Pixel Art Normalizer
  • image
  • normalized
  • block_size
  • downscaled
block_size4
n_colors32

Pixel Art Normalizer is the "make this actually pixel art" node. Feed it something that almost is - an upscaled sprite with blurry edges, an AI render with a pixel-art prompt that came out soft, a scan with uneven pixels - and it figures out the underlying pixel grid, snaps every cell to a uniform block, and quantizes the colors down to a clean palette. You get back three outputs: the normalized image, the block size it detected, and a downscaled 1:1 version. It's the pack's answer to "I want real pixel art, not an approximation."

Where this sits: it's the cleanup half of a pixel-art pipeline. The pack's README pitches "true mathematical pixel art normalization," and that's accurate - there's no ML anywhere in this node. The mechanism is classic CV: the image is converted to grayscale, Canny edge detection finds the hard boundaries, and Hough line detection measures the spacing between parallel lines to estimate the pixel grid size. The image is then padded to a multiple of that grid, each cell is averaged into a single uniform block (which is what removes the soft, blurry edges), and the result is color-quantized down to n_colors using KMeans clustering. All of it is editable: block_size (0–8, default 4) and n_colors (0–256, default 32) both accept 0 for auto-detection, and the detected block size comes out of the block_size output so you can see what it found and correct it if the auto-detect guessed wrong.

The auto-detection is the part to watch. It works beautifully on clean, obviously-gridded art, and it can struggle on busy or noisy images where Hough line detection latches onto the wrong spacing - the code even clamps its guess between 2 and 8 pixels. If the normalized output looks wrong, the fix is simple: set block_size manually instead of 0. Similarly, if your palette comes out either muddy (too many colors) or posterized (too few), hand-set n_colors rather than trusting auto. The three outputs are normalized (the cleaned-up image), block_size (the detected integer), and downscaled (the true 1:1 pixel-art version before upscaling), which is the one you'd feed into an upscaler or train on.

One dependency trap is real, so call it out early: this node imports sklearn (KMeans) at module level, and the pack ships no requirements.txt. Standard ComfyUI installs don't always have scikit-learn. If the entire AnotherUtils pack fails to import with an error mentioning KMeans or sklearn, pip install scikit-learn (plus scipy, which its sibling Smart Resize imports) fixes it.

Beyond that it's the usual zero-drama install: ComfyUI Manager → search "AnotherUtils", or cd ComfyUI/custom_nodes && git clone https://github.com/marcoc2/ComfyUI-AnotherUtils, then restart. No model files, no downloads - just numpy, OpenCV and sklearn doing the work.

Categoryimage/processing

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
block_sizeINT40–8
n_colorsINT320–256

Outputs (3)

NameTypeDescription
normalizedIMAGE
block_sizeINT
downscaledIMAGE