SMIL  1.0.4
extinction_values.py
1 from smilPython import *
2 
3 imIn = Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
4 imGrad = Image(imIn)
5 imMark = Image(imIn, "UINT16")
6 imBasins = Image(imMark)
7 
8 gradient(imIn, imGrad)
9 hMinimaLabeled(imGrad, 5, imMark)
10 
11 nRegions = 25
12 extType = "v"
13 
14 # Graph version
15 
16 imGraphOut = Image(imMark)
17 g = watershedExtinctionGraph(imGrad, imMark, imBasins, extType)
18 g.removeLowEdges(nRegions)
19 graphToMosaic(imBasins, g, imGraphOut)
20 # Re-labelize (usefull only to have the same label values in both versions)
21 label(imGraphOut, imGraphOut)
22 imGraphOut.showLabel()
23 
24 
25 # Image version
26 
27 imImgOut = Image(imMark)
28 watershedExtinction(imGrad, imMark, imImgOut, imBasins, extType)
29 compare(imImgOut, ">", nRegions, 0, imMark, imMark);
30 basins(imGrad, imMark, imImgOut)
31 # Re-labelize (usefull only to have the same label values in both versions)
32 label(imImgOut, imImgOut)
33 imImgOut.showLabel()
RES_T compare(const Image< T1 > &imIn1, const char *compareType, const Image< T1 > &imIn2, const Image< T2 > &trueIm, const Image< T2 > &falseIm, Image< T2 > &imOut)
compare() - Compare each pixel of two images (or an image and a value)
Definition: DImageArith.hpp:1244
RES_T hMinimaLabeled(const Image< T1 > &imIn, const T1 &height, Image< T2 > &imOut, const StrElt &se=DEFAULT_SE)
hMinimaLabeled() - Calculate the h-minima and labelize them
Definition: DMorphoExtrema.hpp:182
size_t label(const Image< T1 > &imIn, Image< T2 > &imOut, const StrElt &se=DEFAULT_SE)
label() - Image labelization
Definition: DMorphoLabel.hpp:564
RES_T gradient(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE)
gradient() - Morphological gradient
Definition: DMorphoResidues.hpp:62
RES_T watershedExtinctionGraph(const Image< T > &imIn, const Image< labelT > &imMarkers, Image< labelT > &imBasinsOut, Graph< labelT, outT > &graph, const char *extinctionType="v", const StrElt &se=DEFAULT_SE)
Calculation of the minimum spanning tree, simultaneously to the image flooding, with edges weighted a...
Definition: DMorphoWatershedExtinction.hpp:602
RES_T basins(const Image< T > &imIn, const Image< labelT > &imMarkers, Image< labelT > &imBasinsOut, const StrElt &se=DEFAULT_SE)
Constrained basins.
Definition: DMorphoWatershed.hpp:364