Nodes/comfyui_cv/Colorize Superpixels (FLANN)
ComfyUI Node

Colorize Superpixels (FLANN)

Colorizes a grayscale image using a color reference image via FLANN-based superpixel matching. Internally extracts stride-2 patch features, builds a PCA feature space from the reference, segments both images into superpixels (SLIC), matches gray superpixels to color superpixels via FLANN KDTree kNN, and transfers a/b chrominance through distance-weighted kernel regression with guided filter cleanup.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
Colorize Superpixels (FLANN)
  • target
  • reference
  • image
  • success
n_seg300
k8
flann_checks16
flann_trees5
guided_r12
guided_eps0.04
Categoryimage/CV/colorize

Inputs (8)

NameTypeDefaultDescription
targetIMAGEGrayscale image to colorize (converted to grayscale internally, so a color image also works).
referenceIMAGEColor reference whose a/b palette is transferred. The target's own luminance structure is preserved.
n_segINT30010–5000Number of SLIC superpixels. More segments = finer color detail but slower.
kINT81–128kNN neighbors. Higher = smoother, more blending.
flann_checksoptINT161–1024FLANN KDTree search checks. Higher = more accurate, slower.
flann_treesoptINT51–50FLANN KDTree tree count. More trees = faster queries, more memory.
guided_roptINT120–100Guided filter radius (0 = disabled). Smooths chrominance while respecting luminance edges.
guided_epsoptFLOAT0.040–10Guided filter epsilon squared. Higher = smoother, less edge-aware.

Outputs (2)

NameTypeDescription
imageIMAGEColorized result: target luminance + reference chrominance transferred via FLANN superpixel matching.
successBOOLEANFalse when the pipeline could not produce a result (empty input, no valid segments, FLANN found no matches).