1from smilPython import *
2
3class myWSFlooding(WatershedFlooding_UINT8_UINT16):
4 def initialize(self, imIn, imLbl, imOut, se):
5
6 WatershedFlooding_UINT8_UINT16.initialize(self, imIn, imLbl, imOut, se)
7 self.imgWS.updatesEnabled = True
8 self.imgLbl.updatesEnabled = True
9 self.nbrPixProcessed = 0
10 self.refresh_every = 10
11 return RES_OK
12 def processPixel(self, offset):
13
14 WatershedFlooding_UINT8_UINT16.processPixel(self, offset)
15 if self.nbrPixProcessed>=self.refresh_every:
16 self.imgWS.modified()
17 self.imgLbl.modified()
18 Gui.processEvents()
19 self.nbrPixProcessed = 0
20 else:
21 self.nbrPixProcessed += 1
22
23
24if not "imIn" in globals():
25 imIn = Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
26 imGrad = Image(imIn)
27 imWS = Image(imIn)
28 imMark = Image(imIn, "UINT16")
29 imBasins = Image(imIn, "UINT16")
30
31gradient(imIn, imGrad)
32hMinimaLabeled(imGrad, 10, imMark)
33
34imGrad.show()
35imWS.showLabel()
36imBasins.showLabel()
37
38wsFlood = myWSFlooding()
39wsFlood.flood(imIn, imMark, imWS, imBasins, sSE())
40
41
42
43