template<class T, class labelT, class extValType = UINT, class HQ_Type = HierarchicalQueue<T>>
class smil::ExtinctionFlooding< T, labelT, extValType, HQ_Type >
Generic extinction flooding process.
Can be derivated in wrapped languages thanks to Swig directors.
Example
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")
gradient(imIn, imGrad)
hMinimaLabeled(imGrad, 25, imMark)
aExt = myAreaExtinction()
aExt.floodWithExtRank(imIn, imMark, imExtRank)
imExtRank.showLabel()