1from smilPython import *
2
3imIn = Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
4imGrad = Image(imIn)
5imMark = Image(imIn, "UINT16")
6imBasins = Image(imMark)
7
8gradient(imIn, imGrad)
9hMinimaLabeled(imGrad, 5, imMark)
10
11nRegions = 25
12extType = "v"
13
14
15
16imGraphOut = Image(imMark)
17g = watershedExtinctionGraph(imGrad, imMark, imBasins, extType)
18g.removeLowEdges(nRegions)
19graphToMosaic(imBasins, g, imGraphOut)
20
21label(imGraphOut, imGraphOut)
22imGraphOut.showLabel()
23
24
25
26
27imImgOut = Image(imMark)
28watershedExtinction(imGrad, imMark, imImgOut, imBasins, extType)
29compare(imImgOut, ">", nRegions, 0, imMark, imMark);
30basins(imGrad, imMark, imImgOut)
31
32label(imImgOut, imImgOut)
33imImgOut.showLabel()