Generic extinction flooding process.
Can be derivated in wrapped languages thanks to Swig directors.
from smilPython import *
class myAreaExtinction(ExtinctionFlooding_UINT8_UINT16):
def createBasins(self, nbr):
self.areas = [0]*nbr
ExtinctionFlooding_UINT8_UINT16.createBasins(self, nbr)
def insertPixel(self, offset, lbl):
self.areas[lbl] += 1
def mergeBasins(self, lbl1, lbl2):
if self.areas[lbl1] > self.areas[lbl2]:
eater = lbl1
eaten = lbl2
else:
eater = lbl2
eaten = lbl1
self.extinctionValues[eaten] = self.areas[eaten]
self.areas[eater] += self.areas[eaten]
return eater
def finalize(self, lbl):
self.extinctionValues[lbl] += self.areas[lbl]
imIn = Image("https://smil.cmm.minesparis.psl.eu/images/lena.png")
imGrad = Image(imIn)
imMark = Image(imIn, "UINT16")
imExtRank = Image(imIn, "UINT16")
aExt = myAreaExtinction()
aExt.floodWithExtRank(imIn, imMark, imExtRank)
imExtRank.showLabel()
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
RES_T gradient(const Image< T > &imIn, Image< T > &imOut, const StrElt &se=DEFAULT_SE)
gradient() - Morphological gradient
Definition: DMorphoResidues.hpp:62