1import smilPython as sp
2
3im = sp.Image("balls.png")
4iml = sp.Image(im)
5
6
7sp.label(im, iml)
8iml.showLabel()
9
10
11blobs = sp.computeBlobs(iml)
12
13
14areas = sp.blobsArea(blobs)
15barys = sp.blobsBarycenter(im, blobs)
16
17
18print("{:3s} - {:>6s} - {:>13s}".format("ID", "Area", "Barycenter"))
19for k in blobs.keys():
20 bary = barys[k]
21 print("{:3d} - {:6.0f} - {:6.0f} {:6.0f}".format(k, areas[k], bary[0], bary[1]))
22