SMIL 1.1.1
Loading...
Searching...
No Matches
constrained_watershed.py
1from smilPython import *
2
3# Load an image
4imIn = Image("https://smil.cmm.minesparis.psl.eu/images/DNA_small.png")
5imIn.show()
6
7# Create a gradient image
8imGrad = Image(imIn)
9gradient(imIn, imGrad)
10
11# Manually impose markers on image
12imMark = Image(imIn, "UINT16")
13imMark << 0
14# One for the background...
15imMark.setPixel(75, 40, 1)
16# and one on two connected particules
17imMark.setPixel(78, 86, 2)
18imMark.setPixel(88, 76, 3)
19
20# Dilate the markers to avoid to be blocked in a minimum
21dilate(imMark, imMark, 2)
22#imMark.showLabel()
23
24# Create the watershed
25imWS = Image(imIn)
26watershed(imGrad, imMark, imWS)
27
28# Display output
29imWS.show()
30
31# Display the output as overlay on the original image
32imIn.getViewer().drawOverlay(imWS & 1)
33