Nodes/ComfyUI_KubaNodes/kubakub regions from sketch
ComfyUI Node

kubakub regions from sketch

Every closed shape of a drawing becomes a region. Hand-drawn strokes rarely meet: each stroke end is extended to the next line within gap_px. A dot of coloured marker inside a shape names it: the region gets the colour as tag and name (red_1 ...), so plan rules like [tag:red] pick it. Shapes drawn alike (all the windows) land in one group.

By kubakubkub·Created 15 days ago·Updated 3 days ago· 9
kubakub regions from sketch
  • drawing
  • line
  • matrix
  • scope
  • regions
  • region_masks
  • regions_json
  • preview
  • report
  • closed_lines
◄gap_px24►
◄line_threshold0.30►
◄colour_namestrue►
◄outsidekeep►
◄min_region_area400►
◄merge_small_regionstrue►
Categorykubakub/2d/sketch

Inputs (10)

NameTypeDefaultDescription
drawingIMAGEFrom kubakub scan to line (or any line drawing on white).
gap_pxINT240–500Largest gap between strokes that still closes a shape (pixels of the drawing).
line_thresholdFLOAT0.300.01–0.99How strong a stroke must be to count as a wall between shapes.
colour_namesBOOLEANtrueColoured marker dots name the shape they sit in (and are no wall).
outsideCOMBOkeepdrop = shapes touching the edge of the paper are no regions (the sky around a drawn building).
min_region_areaINT4000–100000000Shapes smaller than this (pixels) - hatching, little marks - are merged or dropped.
merge_small_regionsBOOLEANtrueOn: small shapes join the neighbour with the longest border. Off: dropped.
lineoptMASKThe line output of scan to line (better than the drawing alone).
matrixoptIMAGEYour matrix: the preview background, and the size of the regions (a drawing of another size is fitted to it; same proportions only).
scopeoptMASKPixels outside this mask are never part of a region (the size of the matrix, or of the drawing without one).

Outputs (6)

NameTypeDescription
regionsKUBA_REGIONSLabel map + region table for the kubakub region nodes.
region_masksMASKOne mask per region; batch index = region_id.
regions_jsonSTRINGThe region table as text.
previewIMAGERegions over the drawing (or the matrix), one colour per group.
reportSTRINGRegions and groups found, gaps bridged, shapes named by colour, small shapes merged or dropped.
closed_linesMASKThe lines the shapes were cut with: your strokes plus the bridges over the gaps (white = wall). Shows where gap_px closed a shape, or still leaves one open.