SMIL  1.0.4
interactive_segmentation.py
1 from smilPython import *
2 
3 
4 im1 = Image("https://smil.cmm.minesparis.psl.eu/images/tools.png")
5 im2 = Image(im1)
6 im3 = Image(im1)
7 im4 = Image(im1)
8 imOverl = Image(im1)
9 
10 gradient(im1, im2)
11 
12 im1.show()
13 im3.show()
14 im4.showLabel()
15 
16 v = im1.getViewer()
17 
18 class slot(EventSlot):
19  def run(self, event=None):
20  v.getOverlay(imOverl)
21  watershed(im2, imOverl, im3, im4)
22 
23 s = slot()
24 
25 v.onOverlayModified.connect(s)
26 v.onOverlayModified.trigger()
27 
28 
29 print("1) Right click on im1")
30 print("2) In the \"Tools\" menu select \"Draw\"")
31 print("3) Draw markers (with different colors) on im1 and view the resulting segmentation")
32 
33 # Will crash if not in a "real" Qt loop
34 Gui.execLoop()
35 
RES_T gradient(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE)
gradient() - Morphological gradient
Definition: DMorphoResidues.hpp:62
RES_T watershed(const Image< T > &imIn, const Image< labelT > &imMarkers, Image< T > &imOut, Image< labelT > &imBasinsOut, const StrElt &se=DEFAULT_SE)
Constrained watershed.
Definition: DMorphoWatershed.hpp:402