Nodes/MKRShift_Nodes/Color Region Mask
ComfyUI Node

Color Region Mask

Isolate a color family without a paint brush

By criskb·Created 7 months ago·Updated 5 months ago· 0
Color Region Mask
  • image
  • source_mask
  • mask
  • image
  • mask
  • region_info
color_preset
hue_center0.000
hue_width0.080
saturation_min0.18
value_min0.04
softness0.050
contrast1.15
blur_radius0.0
invert_valuesfalse
mask_feather8.0
invert_maskfalse

"Make a mask of just the red bits" is one of those jobs you end up hand-painting more often than you'd like. x1ColorRegionMask builds a grayscale mask for a selected color family - red, green, blue, any of the presets, or a custom hue center - from a texture or painted map, in seconds. It's from MKRShift Nodes' Surface/Maps branch, and it's aimed at material work: splitting a source into zones before you run roughness, metalness, wear, or packing passes on each zone separately.

The pack is young (no impressions yet, nothing on Reddit when I checked), so treat it as fresh but clean code. What it does, it does deterministically on the CPU - no models.

How it works

The mechanism is standard hue-based selection with one smart addition. It computes the hue of each pixel, selects a region defined by color_preset (or custom + hue_center), and opens it up with hue_width. Then comes the part that keeps the mask usable: it suppresses low-saturation and near-black pixels via saturation_min and value_min, so neutral shading and dark shadows don't flood the result. That's the difference between a hue mask that looks like a cloud and one that actually isolates the painted red zone. softness feathers the hue falloff, contrast punches the result, blur_radius cleans it up, and invert_values flips it.

Outputs: image (grayscale mask as an image), mask (the scalar mask - the thing you wire onward), and region_info (settings log). The optional source_mask gates the source sampling, and mask / mask_feather limit where the output is emitted.

Inputs that matter

  • color_preset - start with a family, switch to custom + hue_center when the preset is off by a few degrees
  • hue_width - narrower isolates tighter, softness adds the gentle edge when narrow is too harsh
  • saturation_min - the anti-flood control; raise it when the mask is covering too much neutral area

The workflow it feeds

The author's own note is the best pointer: reach for this when a source is too messy for x1IDMapQuantize or x1IDMaskExtract. It's for splitting material zones - "the red part gets rough metalness, the blue part gets wear." x1ScalarMapAdjust is the designated follow-up when you want a harder or softer final mask.

Installing

ComfyUI Manager → search MKRShift Nodes, or:

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

Restart ComfyUI. No models, no new dependencies.

Where people get burned

  • Hue wraps around. Red lives at both 0° and 360°, so custom hue selection around red needs care - if your custom center is at the wrap point, the mask can grab the wrong half of the wheel. The presets handle this correctly; be careful hand-dialing near the wrap.
  • Skipping saturation_min. On flat, desaturated textures a hue-only mask is mostly noise; this node's flood control exists precisely because that failure is common.
  • mask output vs. mask input - the output is the derived scalar, the input is the emission gate. Same pack-wide convention.

For material zone splits, wear placement, or "this specific color becomes the roughness driver," it's the fast, honest way to get there.

CategoryMKRShift Nodes/Surface/Maps

Inputs (14)

NameTypeDefaultDescription
imageIMAGE
color_presetCOMBO8 options: red, orange, yellow, green, cyan, blue, +2
hue_centerFLOAT0.0000–1
hue_widthFLOAT0.0800.001–0.5
saturation_minFLOAT0.180–1
value_minFLOAT0.040–1
softnessFLOAT0.0500–0.5
contrastFLOAT1.150.1–4
blur_radiusFLOAT0.00–128
invert_valuesBOOLEANfalse
mask_featherFLOAT8.00–256
invert_maskBOOLEANfalse
source_maskoptMASK
maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
region_infoSTRING