Nodes/comfyui_cv/CV Region Properties
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.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
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)

NameTypeDefaultDescription
maskMASKA 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).
connectivityCOMBO88 also connects diagonal pixels; 4 only direct neighbours. Only used when splitting a single mask.
propertiesSTRINGcentroid (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.
scaleCOMBOraw (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_areaoptINT00–2147483647Regions smaller than this many pixels are dropped (0 keeps every region). Specks are what make a cluster count meaningless.
on_emptyoptCOMBOempty 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.
imageoptIMAGEOnly 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)

NameTypeDescription
featuresNPARRAY(N, D) float32, one row per region in label order. N = 0 for an empty mask.
labelsNPARRAY[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.
namesSTRINGThe column names, comma separated - wire it into 'Preview as Text' to read the matrix.
countINTN, the number of regions measured.