SMIL  0.8
 All Classes Functions Variables Groups Pages
watershed_live.py

1 from smilPython import *
2 
3 class myWSFlooding(WatershedFlooding_UINT8_UINT16):
4  def initialize(self, imIn, imLbl, imOut, se):
5  # Call parent class method
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 = 1 # refresh every n pixels processed
11  return RES_OK
12  def processPixel(self, offset):
13  # Call parent class method
14  WatershedFlooding_UINT8_UINT16.processPixel(self, offset)
15  if self.nbrPixProcessed>=self.refresh_every:
16  self.imgWS.modified()
17  self.imgLbl.modified()
18  self.nbrPixProcessed = 0
19  else:
20  self.nbrPixProcessed += 1
21 
22 
23 if not "imIn" in globals():
24  imIn = Image("http://cmm.ensmp.fr/~faessel/smil/images/lena.png")
25  imGrad = Image(imIn)
26  imWS = Image(imIn)
27  imMark = Image(imIn, "UINT16")
28  imBasins = Image(imIn, "UINT16")
29 
30 gradient(imIn, imGrad)
31 hMinimaLabeled(imGrad, 10, imMark)
32 
33 imGrad.show()
34 imWS.showLabel()
35 imBasins.showLabel()
36 
37 wsFlood = myWSFlooding()
38 wsFlood.flood(imIn, imMark, imWS, imBasins, sSE())
39 
40 
41 
42