1import smilPython as sp
2import time
3
4thresh = 1000
5
6im = sp.Image("https://smil.cmm.minesparis.psl.eu/images/balls.png")
7iml = sp.Image(im)
8img = sp.Image(im)
9ims = sp.Image(im)
10
11sp.label(im, iml)
12
13im.show("balls.png")
14iml.showLabel("iml")
15
16sp.areaThreshold(iml, thresh, True, img)
17img.showLabel("img")
18sp.areaThreshold(im, thresh, False, ims)
19ims.show("ims")
20
21nlold = 0
22for threshold in range(1, 6000, 20):
23 sp.areaThreshold(im, threshold, True, ims)
24 nl = sp.label(ims, iml)
25 if nl != nlold:
26 print(' Threshold {:6d} : {:3d} blobs'.format(threshold, nl))
27 sp.Gui.processEvents()
28 time.sleep(1)
29 if nl == 0:
30 break
31 nlold = nl