Blobs.parent#

property Blobs.parent: Any#

Parent blob

Returns:

index of this blob’s parent

Return type:

int

Example:

>>> from machinevisiontoolbox import Image
>>> im = Image.Read('multiblobs.png')
>>> blobs = im.blobs()
>>> print(blobs)
┌────┬────────┬───────────────┬──────────┬───────┬────────┬────────┬─────────┬────────┐
│ id │ parent │      centroid │     area │ touch │  perim │ circul │  orient │ aspect │
├────┼────────┼───────────────┼──────────┼───────┼────────┼────────┼─────────┼────────┤
│  0 │     -1 │  907.9, 735.1 │ 1.94e+05 │ False │ 2219.0 │  0.551 │ -103.6° │  0.814 │
│  1 │      0 │ 1025.0, 813.7 │ 1.06e+05 │ False │ 1386.9 │  0.770 │  -90.0° │  0.802 │
│  2 │      1 │  938.1, 855.2 │ 1.72e+04 │ False │  489.7 │  1.005 │  -12.5° │  0.945 │
│  3 │      1 │  988.1, 697.2 │ 1.21e+04 │ False │  411.5 │  0.999 │ -102.8° │  0.919 │
│  4 │      0 │  846.0, 511.7 │ 1.75e+04 │ False │  495.9 │  0.996 │  -90.1° │  0.871 │
│  5 │     -1 │  291.7, 377.8 │  1.7e+05 │ False │ 1711.6 │  0.811 │ -102.9° │  0.775 │
│  6 │      5 │  312.7, 472.1 │ 1.75e+04 │ False │  494.5 │  1.001 │  -90.2° │   0.87 │
│  7 │      5 │  241.9, 245.0 │ 1.75e+04 │ False │  495.9 │  0.996 │  -90.1° │  0.871 │
│  8 │     -1 │ 1228.0, 254.3 │ 8.14e+04 │ False │ 1214.2 │  0.772 │ -102.9° │  0.651 │
│  9 │      8 │ 1225.2, 220.0 │ 1.75e+04 │ False │  495.9 │  0.996 │  -90.0° │  0.871 │
└────┴────────┴───────────────┴──────────┴───────┴────────┴────────┴─────────┴────────┘
>>> blobs[5].parent
-1
>>> blobs[6].parent
5

A parent of -1 is the image background.

Seealso:

id children level dotfile