blob_stats
result = blob_stats(img)
Input: img · Output: result
What it is
img is a Model produced by label_blobs/bwlabel. Per-region area, centroid and bounding box, from a labelled image (identical operation to regionprops above).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = blob_stats(img) | img Modelnot documented yet | result List or Record | Returns a List of Records, one per blob. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
m = [255, 255, 0, 0, 0, 0; 255, 255, 0, 255, 0, 0; 0, 0, 0, 0, 0, 0; 0, 255, 0, 0, 0, 0; 0, 0, 0, 0, 255, 255; 0, 0, 0, 0, 255, 255]
binary = image_from_matrix(m)
cleaned = remove_small_blobs(binary, 3) # drop the two 1-pixel specks
imshow(cleaned)
labeled = label_blobs(cleaned)
stats = blob_stats(labeled)
for i = 1 to labeled.count
r = stats[i - 1]
print(r.label, r.area, r.centroid_x, r.centroid_y)
end for
1 4 0.5 0.5 2 4 4.5 4.5
from images
How it works
blob_stats(labeled) (alias regionprops) — per-blob geometry from a label_blobs/bwlabel result: a Value::List of one Value::Record per blob (label, area, centroid_x, centroid_y, bbox_x, bbox_y, bbox_width, bbox_height), in label-id order. centroid_x/centroid_y are the real arithmetic mean of that blob's own pixel coordinates (not a bounding-box-center approximation); bbox_* is the tightest axis-aligned rectangle containing every one of that blob's pixels.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.