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.
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)
| Name | Type | Default | Description |
|---|---|---|---|
| drawing | IMAGE | From kubakub scan to line (or any line drawing on white). | |
| gap_px | INT | 240–500 | Largest gap between strokes that still closes a shape (pixels of the drawing). |
| line_threshold | FLOAT | 0.300.01–0.99 | How strong a stroke must be to count as a wall between shapes. |
| colour_names | BOOLEAN | true | Coloured marker dots name the shape they sit in (and are no wall). |
| outside | COMBO | keep | drop = shapes touching the edge of the paper are no regions (the sky around a drawn building). |
| min_region_area | INT | 4000–100000000 | Shapes smaller than this (pixels) - hatching, little marks - are merged or dropped. |
| merge_small_regions | BOOLEAN | true | On: small shapes join the neighbour with the longest border. Off: dropped. |
| lineopt | MASK | The line output of scan to line (better than the drawing alone). | |
| matrixopt | IMAGE | Your matrix: the preview background, and the size of the regions (a drawing of another size is fitted to it; same proportions only). | |
| scopeopt | MASK | Pixels outside this mask are never part of a region (the size of the matrix, or of the drawing without one). |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| regions | KUBA_REGIONS | Label map + region table for the kubakub region nodes. |
| region_masks | MASK | One mask per region; batch index = region_id. |
| regions_json | STRING | The region table as text. |
| preview | IMAGE | Regions over the drawing (or the matrix), one colour per group. |
| report | STRING | Regions and groups found, gaps bridged, shapes named by colour, small shapes merged or dropped. |
| closed_lines | MASK | The 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. |