Nodes/ComfyUI_Mira/PngColor Masks to Masks
ComfyUI Node

PngColor Masks to Masks

Turn a color-block layout into real masks

By mirabarukaso·Created 2 years ago·Updated 5 days ago· 206
PngColor Masks to Masks
  • PngImage
  • PngColorMasks
  • mask_0
  • mask_1
  • mask_2
  • mask_3
  • mask_4
  • mask_5
  • mask_6
  • mask_7
  • mask_8
  • mask_9
Blur0.0
Start_At_Index0

This is the node that takes the colorful block-diagram you built with Create Tilling PNG Mask (or Create Nested PNG Mask) and hands you back actual MASK outputs - one per region, ready to wire into regional conditioning. It's the bridge between "I drew where each character goes" and "the sampler actually knows."

If you've never touched regional prompting, here's the why. Conditioning in Stable Diffusion is global: one prompt paints the whole canvas. Describe two characters and they swap hair color, clothes, and pose - attribute bleed, the single most common reason people reach for regional tools in the first place. It's been a steady need for years, not a fad. The fix is to slice the canvas into areas and give each its own prompt, and to do that you need a mask per area. That's what this node produces.

How it works

The Mira mask flow has two halves. The Create PNG Mask nodes generate a visualization image plus a PngColorMasks list - each region is just a distinct flat color (region 0 might be red, region 1 blue, and so on). Nothing is a real mask yet; it's color metadata riding alongside the rendered image. This node reads that color list against the image pixels and, for each color, extracts the pixels matching it into a proper grayscale MASK.

The author's own README admits the awkward part up front - ComfyUI has no clean "list of masks" primitive, so instead of one tidy list output you get ten numbered sockets.

The inputs that matter

  • PngImage - the visualization IMAGE straight out of the Create PNG Mask node. This is the pixel source the colors get matched against, so don't run it through a resize or color adjust first or the matching breaks.
  • PngColorMasks - the MIRA_COLOR_LIST from that same node. It carries which colors map to which region.
  • Blur - feathers the mask edge. 0 gives a hard edge; bump it up (the README example uses 16.0) to soften the seam between regions so they blend instead of looking collaged. Softer seams are genuinely the thing that separates a good regional result from an obvious cut-and-paste.
  • Start_At_Index - which region to start from if you don't want mask_0. Handy when your first block is background you're handling separately.

The outputs

Ten sockets, mask_0 through mask_9, each a MASK. You wire each one into the region input of your conditioning node - Inspire Pack's Regional Conditioning by Color Mask, ComfyUI's native mask-based conditioning, or anything else that takes a MASK. Only the first N are populated for an N-region layout; leave the rest unconnected.

Installing it

ComfyUI Manager is the easy path: open Manager -> Custom Nodes Manager, search ComfyUI_Mira, Install, restart. Manual works too:

cd ComfyUI/custom_nodes
git clone https://github.com/mirabarukaso/ComfyUI_Mira.git

Restart ComfyUI. If you get a load error on startup, run pip install -r requirements.txt inside the ComfyUI_Mira folder and restart again. No model downloads for the mask nodes.

Common issues

The number-one gotcha: this node is useless on its own. It only understands the PngColorMasks/PngImage pair from a Mira Create PNG Mask node - feed it a random image and it has no color legend to work from. Keep the image and the color list coming from the same generator node, un-edited.

Getting hard seams where regions meet? Raise Blur. The regional-prompting playbook is that holding hard masks through the whole sample is exactly what produces the visible-seam collage look - soft edges (and, if your conditioning setup supports it, ending the masking early) are what fix it.

And keep in mind this is a niche, one-person pack - the author, mirabarukaso, is better known for their WAI Character Select app, and the whole thing exists because they wanted nodes they were comfortable with. Community threads are thin, so the README's own regional-conditioning example is your best reference for how the graph is meant to fit together.

CategoryMira/Mask

Inputs (4)

NameTypeDefaultDescription
PngImageIMAGE
PngColorMasksMIRA_COLOR_LIST
BlurFLOAT0.0
Start_At_IndexINT0

Outputs (10)

NameTypeDescription
mask_0MASK
mask_1MASK
mask_2MASK
mask_3MASK
mask_4MASK
mask_5MASK
mask_6MASK
mask_7MASK
mask_8MASK
mask_9MASK