ComfyUI Node
CV Region Properties
Measures every region of a mask and emits one ROW per region: position, size, shape ratios, orientation and (with an image wired in) mean colour, selected column by column with the checkboxes. A single mask is split into its connected blobs; a MASK batch (segmentation output) is one region per frame. The 'labels' map indexes the same regions - row i-1 describes label i - so a per-region result can be painted back with 'CV Take By Index'. Feed 'features' to cv2.kmeans to group regions, to 'CV Train Classifier' to label them, or to 'CV Chart Scatter' to look at them. An empty mask gives 0 rows, not an error.
CV Region Properties
- mask
- image
- features
- labels
- names
- count
◄connectivity8►
◄propertiescentroid (x, y)►
◄scaleraw (pixels)►
◄min_area0►
◄on_emptyempty table (0 rows)►
Categoryimage/CV/contours
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | A single mask is split into its connected blobs; a MASK batch clusters the masks themselves (one region per frame, resized to frame 0's size). | |
| connectivity | COMBO | 8 | 8 also connects diagonal pixels; 4 only direct neighbours. Only used when splitting a single mask. |
| properties | STRING | centroid (x, y) | Which columns to emit. The position choice is exclusive (a region has one place); everything else is an independent toggle, so 'no position | area' measures size alone. Columns come out in the order listed here, whatever order you tick them in; 'names' spells the final list out. Most toggles emit ONE column, but the two orientation pairs, 'centroid offset in bbox' and 'min-area rect centroid clearance' emit two, 'mean colour' three and 'hu moments (log magnitude)' SEVEN - that last one groups regions by SHAPE alone. Each toggle carries its own tooltip. |
| scale | COMBO | raw (pixels) | raw keeps pixel units - the honest measurement. image-relative divides lengths by the frame size and areas by its area, so the numbers survive a resize. z-score centres each column and divides by its standard deviation, which is what a distance-based consumer (k-means, kNN) needs: raw, an area in px^2 outweighs a centroid in px by thousands. |
| min_areaopt | INT | 00–2147483647 | Regions smaller than this many pixels are dropped (0 keeps every region). Specks are what make a cluster count meaningless. |
| on_emptyopt | COMBO | empty table (0 rows) | What to emit when the mask has no regions at all. The empty table is the honest answer, but a consumer that cannot take 0 rows - cv2.kmeans asserts on an empty sample set - needs the padded row instead. 'count' stays 0 either way, so the row is never mistaken for a measurement. |
| imageopt | IMAGE | Only needed for the 'mean colour' / 'mean intensity' columns: the picture the mask belongs to, at the same size. Frame 0 of a batch. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| features | NPARRAY | (N, D) float32, one row per region in label order. N = 0 for an empty mask. |
| labels | NPARRAY | [H,W] int32 label map: 0 = background, i = the region described by row i-1. Feed it to 'CV Take By Index' with a per-region table, or to 'OpenCV Labels to Masks' to get the regions back. |
| names | STRING | The column names, comma separated - wire it into 'Preview as Text' to read the matrix. |
| count | INT | N, the number of regions measured. |