Set up ComfyUI

Background removal and palette experiments

ComfyUI 0.34.3 has the required nodes in core. No custom-node package is needed. The tested isolated-asset graph runs these nodes in this order:

  1. Decode the 1024×1024 SDXL image.
  2. Run RemoveBackground with the loaded BiRefNet model.
  3. Invert the returned background mask for use as foreground alpha.
  4. Run ImageQuantize on the RGB image with 64 colors and no dithering.
  5. Join the quantized RGB image with the alpha mask.
  6. Reduce the RGBA result with ImageScale set to nearest-exact.

This graph tests the cleanup nodes; it is not the recommended final pipeline. BiRefNet sees the full-resolution color image, so the graph preserves its alpha mask. Quantizing before reduction does not cap the later native-grid palette, because grid recovery can introduce averaged colors.

For an isolated production candidate, use this order instead:

  1. decode the full-resolution model output;
  2. remove its background and preserve the alpha mask;
  3. recover the native pixel grid without resampling the alpha edge;
  4. quantize the recovered native RGB image to the final project palette;
  5. audit and review the final native RGBA file.

Scenic backgrounds skip background removal. They still need grid recovery, final palette enforcement, and review.

The post-processing benchmark reuses the same prompts, seeds, SDXL settings, and LoRA strengths as the first ComfyUI run. Its two isolated assets have 60% and 62% transparent pixels and 55 and 58 RGB colors. The two backgrounds use 64 and 60 colors. The original files ranged from 16,811 to 50,985 colors.

Use PixelKiln to keep those requirements enforceable:

pixelkiln audit --style isolated-refined --min-transparency 0.5 --max-colors 64 --check
pixelkiln audit --style background-refined --max-colors 64 --check

Start without dithering for compact game art. Floyd-Steinberg can soften bands, but it adds noisy pixel patterns. Ordered Bayer dithering is easier to art-direct when a project needs deliberate texture. Whichever mode you choose becomes part of the committed workflow hash.