ComfyUI Node
kubakub regions from matrix / masks
Splits a facade matrix (the full projection image at delivery size) into regions, so each window, pier or wall part can be treated on its own. color_regions: one region per flat colour (per connected patch when split_disconnected is on). line_drawing: the closed cells between lines. mask_folder: one region per PNG, named after the file (subfolders too). Scope masks limit where regions may be, split masks give one region per separate shape. Repeated elements get a shared group_id; every region is tagged with the larger masks that cover it (floor, facade ...).
kubakub regions from matrix / masks
- matrix
- scope
- masks
- regions_json
- preview
- scope
- regions
- report
◄modecolor_regions►
◄min_region_area400►
◄merge_small_regionstrue►
◄color_tolerance24►
◄split_disconnectedtrue►
◄group_tolerance0.08►
◄recursivetrue►
◄group_bystem►
◄output_maskstrue►
◄line_threshold0.50►
◄line_polarityauto►
◄line_gap_close_px1►
◄color_names►
◄mask_folder►
◄scope_masks►
◄split_masks►
◄tag_only_masks►
Categorykubakub/2d/regions
Inputs (19)
| Name | Type | Default | Description |
|---|---|---|---|
| matrix | IMAGE | The facade matrix: the full projection image at delivery size (e.g. a 3840x2160 PNG). Only the first image of a batch is used. | |
| mode | COMBO | color_regions | Where the regions come from. color_regions: flat colour fills in the matrix. line_drawing: closed cells of a line drawing. mask_folder: a folder of PNG masks (e.g. exported from After Effects). |
| min_region_area | INT | 4000–100000000 | Regions smaller than this (in pixels) are merged or dropped. |
| merge_small_regions | BOOLEAN | true | On: merge small regions into the neighbour with the longest shared border. Off: drop them (they stay unassigned). |
| color_tolerance | INT | 240–442 | color_regions: colours closer than this (RGB distance, 0-255 units) count as the same fill. |
| split_disconnected | BOOLEAN | true | color_regions: on = every separate patch of a colour is its own region (each window), off = one region per colour. |
| group_tolerance | FLOAT | 0.080–0.5 | How different two regions may be (relative bbox size, 1 - shape IoU) and still share a group_id. 0 = identical only. |
| recursive | BOOLEAN | true | mask_folder: also read PNGs in subfolders (Groups/, Windows/ ...). |
| group_by | COMBO | stem | mask_folder: group_id from the file name without its trailing number (stem) or from the subfolder name (folder). |
| output_masks | BOOLEAN | true | Off: the masks output is a single empty mask, saving RAM when only the regions output is used. |
| line_threshold | FLOAT | 0.500–1 | line_drawing: brightness that separates lines from paper. |
| line_polarity | COMBO | auto | line_drawing: auto takes whichever of dark/light is the minority as the lines. |
| line_gap_close_px | INT | 10–32 | line_drawing: thicken lines by this much first, so small gaps don't leak one cell into the next. |
| color_namesopt | STRING | color_regions: name the groups by matrix colour. Every region of that colour gets the name as group_id. | |
| mask_folderopt | STRING | mask_folder: folder of PNG masks (alpha or white = inside). 'windows_03.png' becomes region 'windows_03' in group 'windows'. Empty: the sample facade's masks at the matrix size, so the node runs as it is. | |
| scope_masksopt | STRING | mask_folder: masks (names or wildcards, comma or one per line) that are not regions but the area regions may use. Nothing outside their union is ever a region. | |
| split_masksopt | STRING | mask_folder: masks holding several separate shapes. Each shape becomes a region <name>_01, _02 ... in reading order, all in group <name>. | |
| tag_only_masksopt | STRING | mask_folder: masks that only tag the regions they cover and are no region themselves. | |
| scopeopt | MASK | Any mode: pixels outside this mask are never part of a region. |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| masks | MASK | One mask per region; batch index = region_id. |
| regions_json | STRING | The region table as text: ids, groups, tags, boxes and notes. |
| preview | IMAGE | The matrix in grey with one colour per group, region borders and ids. |
| scope | MASK | 1 where regions may be (all 1 without a scope). |
| regions | KUBA_REGIONS | Label map + region table for the kubakub region nodes. |
| report | STRING | How many regions and groups were found, pixels left without a region, and the notes (merged or dropped regions, the sample used when no folder is given). |