ComfyUI Node

Image Complexity Map

Tell ETUR where it's safe to get creative

By Ltamann·Created about a year ago·Updated 19 days ago· 156
Image Complexity Map
  • image
  • output_1
  • output_2
methodvariance
window_size15
edge_strength0.40
area_size8
area_stride8
area_metricrange
area_scale_modefixed
area_max_override0.00
area_strength1.00
size_boost_modeoff
ref_area128
gain_power0.5
gain_min0.25
gain_max4.00
diff_large_area64
diff_weight1.00
diff_relufalse
final_blurtrue
blur_radius128
blur_max_radius128
white_modesoft
white_threshold0.010
white_soft_strength2.50
white_gamma0.5

Here's the problem tiled upscaling has had since Ultimate SD Upscale: uniform areas. A sky, a flat wall, a clean background - when you run a generative refiner over tiles, those boring regions are where the model goes off the rails. It invents noise, shifts the color, and by the time you've fused the tiles back together the sky looks like a sandstorm. The standard answer is to denoise heavily on detailed areas and barely at all on flat ones. The problem is that "per-pixel denoise" needs a map of where the detail is.

Image Complexity Map builds that map. It analyzes your input and outputs a grayscale complexity heatmap - bright where there's texture and structure, dark where it's flat - as both an IMAGE and a MASK. Feed that mask into the denoise path of TBG's refiner (via MaskToDenoiseInterpolator or MaskGrayValueScaler) and you get what the README calls the Fusion Complexity Mask: a ControlNet-like behavior that costs zero VRAM, because it's just deciding how hard each pixel gets denoised.

How it works

The node turns the image grayscale, then scores local complexity. The method dropdown picks the detector:

  • variance (default) - local variance within a window_size neighborhood. Texture → high variance → bright. Flat → low variance → dark. The right default for most photos.
  • edges - Canny edge density instead. Better if you want a map that follows line work.
  • hybrid - blends the two; edge_strength (default 0.4) decides how much the edge term contributes.

Below that are the advanced knobs: a block/area pass (area_size, area_stride, area_metric), size-aware boosting (size_boost_mode, ref_area, gain_power) and a multi-scale difference mode for promoting small-scale detail. You can largely ignore those until the defaults don't match your image. The two you'll actually touch:

  • final_blur / blur_radius - the map gets a big Gaussian blur (default radius 128) before output. This matters more than it looks: an unblurred complexity map is spiky and will make the denoise mask look like noise itself. Keep the blur on.
  • white_mode / white_threshold - a final ramp that pushes values above a threshold toward pure white. Leave it on soft unless you want a hard cut.

Outputs: output_1 (IMAGE, the visible map) and output_2 (MASK, the same thing ready to wire into mask inputs).

Wiring it up

The canonical chain is Image Complexity Map → MaskToDenoiseInterpolator (or MaskGrayValueScaler) → the refiner's per-pixel denoise input. The idea is simple: flat areas stay at low denoise so they don't drift, textured areas get the full creative budget. If you're seeing the classic "skies get noisy during refinement" failure, this is the node that fixes it without you hand-painting a mask.

Installing it

Part of the TBG ETUR pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Ltamann/ComfyUI-TBG-ETUR
cd ComfyUI-TBG-ETUR
pip install -r requirements.txt

Or via ComfyUI Manager (search "TBG", install TBG_Enhanced Tiled Upscaler & Refiner FLUX PRO), then restart. It imports OpenCV (cv2), so if the pack's requirements didn't fully install you'll see an import error on this node specifically - that's your cue to pip install opencv-python in the pack venv.

Notes

The map is only as good as your source. If you feed it an already-noisy or overly-sharp image, it'll score the noise as "complexity" and light up the very areas you wanted stabilized. Clean the source first (this pack even ships AI Source Pattern Cleanup for exactly that class of problem), then build the map. And remember the map is a guide, not a verdict - the min/max clamping nodes in this same TBG/Helpers/Mask menu exist so you can stop the map from ever going to pure black and fully silencing refinement on your flat areas.

CategoryTBG/Helpers/Mask

Inputs (25)

NameTypeDefaultDescription
imageIMAGE
methodCOMBOvariance3 options: variance, edges, hybrid
window_sizeINT153–99
edge_strengthFLOAT0.400–1
area_sizeINT80–1024
area_strideINT80–1024
area_metricCOMBOrange3 options: variance, std, range
area_scale_modeCOMBOfixed4 options: fixed, normalize, 0, 1
area_max_overrideFLOAT0.000–10
area_strengthFLOAT1.000–1
size_boost_modeCOMBOoff3 options: off, gain, difference
ref_areaINT1281–1024
gain_powerFLOAT0.50–4
gain_minFLOAT0.250–10
gain_maxFLOAT4.000–10
diff_large_areaINT642–2048
diff_weightFLOAT1.000–4
diff_reluBOOLEANfalse
final_blurBOOLEANtrue
blur_radiusINT1280–255
blur_max_radiusINT1281–255
white_modeCOMBOsoft3 options: off, hard, soft
white_thresholdFLOAT0.0100–1
white_soft_strengthFLOAT2.500–5
white_gammaFLOAT0.50.1–5

Outputs (2)

NameTypeDescription
output_1IMAGE
output_2MASK