Nodes/ComfyUI_Element_easy/BlackWhiteColor
ComfyUI Node

BlackWhiteColor

Split an image into black-and-white regions without wrecking object recognition

By supElement·Created 9 months ago·Updated about 11 hours ago· 10
BlackWhiteColor
  • image
  • mask
  • image
  • mask
  • invert_mask
  • mask_grow
  • invert_mask_grow
contrast1.0
threshold0.50
mask_grow0
invert_mask_grow0

BlackWhiteColor is a thresholding node that turns an image into two crisp regions - a black/white mask split - and it exists because of a very specific, very annoying failure mode: instruction editors like Qwen-Image-Edit re-emit the whole frame, so pixels you didn't touch come back slightly shifted and color-shifted. If you want to edit "only the style of this region," you need a mask, and you need the two regions to be reasonably balanced so the model doesn't get confused. That's exactly the gap this node was built for.

The backstory is worth knowing because it tells you when to reach for it. The author originally made a checkerboard-pattern node to suppress that pixel drift during Qwen-Edit style transfer - convert the masked region's style first, then convert the inverted region in a second pass. The problem: a checkerboard mask actively confuses the model's object recognition. So they built this node instead: a proper thresholded black/white split that produces cleaner regions for the same two-pass trick.

How it works

Feed it an image and it binarizes it: contrast (0–10) boosts the image before thresholding, then threshold (0–1) cuts it into black and white. Lower threshold makes more of the image white; raise it and you get more black. The result is both the split image and the two masks built from it - mask and invert_mask - so you can run a two-pass edit: first sampling with mask driving the edited region, then again with invert_mask.

Two things separate this from a generic threshold node. First, the optional mask input is added to the node's own generated mask, so you can combine a hand-drawn or model-generated mask with the automatic split instead of choosing one. Second, mask_grow and invert_mask_grow (0–64) let you grow each region outward, which is the classic trick for hiding seams: expand the edited region a few pixels past where the style change actually happens so the transition lands somewhere the model handles well.

The author's own advice, straight from the README: keep the black and white areas roughly even in size. When one region is a sliver and the other dominates, the model tends to produce tone inconsistencies between the two passes.

What you actually wire up

  • image in, then the mask and invert_mask outputs go to whatever drives your two sampling passes - ConditioningSetMask or an inpainting/ControlNet path.
  • contrast and threshold are the two knobs you'll tune first; start at the defaults (1 and 0.5) and adjust until the split matches the region you actually want to change.

Installing it

It ships in the supElement/ComfyUI_Element_easy pack, so you install the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/supElement/ComfyUI_Element_easy.git

Then restart ComfyUI. Or open ComfyUI Manager, search ComfyUI_Element_easy, and hit install - Manager pulls in the pack's Python dependencies for you.

Common gotchas

The threshold is doing real work here, so on flat or low-contrast images the split can be noisy - crank contrast before you fight with threshold. And remember the two-pass plan needs two samplings, and the author explicitly notes this approach doesn't work on Klein-based (Flux 2 Klein) editing models, where the pixel-drift fix has to come from somewhere else. If you're here because of Qwen-Edit drift, this is a legit tool for the job; if you're on Klein, don't fight it - this node won't save you.

CategoryElement_easy/image

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
contrastFLOAT1.00–10
thresholdFLOAT0.500–1
mask_growINT00–64
invert_mask_growINT00–64
maskoptMASK

Outputs (5)

NameTypeDescription
imageIMAGE
maskMASK
invert_maskMASK
mask_growMASK
invert_mask_growMASK