KohakuBlueleaf/PixelOE

Detail-Oriented Pixelization based on Contrast-Aware Outline Expansion.

What it solves

PixelOE addresses the loss of fine details and sharp edges that typically occurs when downscaling high-resolution images into pixel art. It prevents the "blurring" or disappearance of key features by ensuring important outlines are preserved during the pixelization process.

How it works

The project uses a two-stage classical image processing pipeline instead of neural networks:

  1. Contrast-Aware Outline Expansion: The system generates a weight map based on local brightness and contrast. It then uses selective morphological operations (erosion and dilation) blended by this weight map to broaden important features and clean up edges before downscaling.
  2. Contrast-Based Downsampling: The image is converted to the LAB color space. The luminance channel is processed using a sliding window that adaptively selects the most representative pixel (based on median, mean, min, and max values) to maintain dark or bright details. Color channels are processed with a median filter before converting back to RGB.

Optional enhancements include color palette optimization via k-means clustering and color matching to the original image.

Who it’s for

It is designed for artists and developers who want to create high-quality pixel art from photos or digital art without needing AI models, as well as users of ComfyUI who want a dedicated pixelization node.

Highlights

  • No AI Required: Uses predictable, classical image processing methods.
  • High Performance: Features a fast PyTorch implementation and an even faster Slang compute-shader backend (CUDA, Vulkan, D3D12, CPU).
  • Detail Preservation: Specifically focuses on contrast-aware outline expansion to keep fine lines sharp.
  • Flexible Integration: Available as a Python library, a CLI tool, a Gradio demo, and a ComfyUI custom node.

Related

  • Project
  • Project
  • Project
  • Project