Esempio n. 1
0
def hierarchy(imIn, imMask, imOut, grid=mamba.DEFAULT_GRID):
    """
    Construction of a hierarchical image from image 'imIn' and with 'imMask'.
    The binary image 'imMask' controls the dual reconstruction (propagation)
    of 'imIn'.
    This operator is mainly used to build hierarchical images from valued
    watershed images.
    The hierarchical image is put in 'imOut'.
    """

    imWrk = mamba.imageMb(imIn)
    if mamba.checkEmptiness(imIn):
        mamba.copy(imIn, imOut)
    else:
        mamba.convertByMask(imMask, imWrk, 255, 0)
        mamba.logic(imIn, imWrk, imWrk, "sup")
        mamba.hierarDualBuild(imIn, imWrk)
        mamba.copy(imWrk, imOut)
Esempio n. 2
0
def hierarchy(imIn, imMask, imOut, grid=mamba.DEFAULT_GRID):
    """
    Construction of a hierarchical image from image 'imIn' and with 'imMask'.
    The binary image 'imMask' controls the dual reconstruction (propagation)
    of 'imIn'.
    This operator is mainly used to build hierarchical images from valued
    watershed images.
    The hierarchical image is put in 'imOut'.
    """
    
    imWrk = mamba.imageMb(imIn)
    if mamba.checkEmptiness(imIn):
        mamba.copy(imIn, imOut)
    else:
        mamba.convertByMask(imMask, imWrk, 255, 0)
        mamba.logic(imIn, imWrk, imWrk, "sup")
        mamba.hierarDualBuild(imIn, imWrk)
        mamba.copy(imWrk, imOut)
Esempio n. 3
0
def deepMinima(imIn, imOut, h, grid=mamba.DEFAULT_GRID):
    """
    Computes the minima of the dual reconstruction of image 'imIn' by 
    imIn + h and puts the result in 'imOut'.
    
    Grid used by the dual build operation can be specified by 'grid'.
    
    Only works with 8-bit or 32-bit images as input. 'imOut' must be binary.
    """
    
    imWrk = mamba.imageMb(imIn)
    if imIn.getDepth() == 8:
        mamba.addConst(imIn, h, imWrk)
        mamba.hierarDualBuild(imIn, imWrk, grid=grid)
    else:
        mamba.ceilingAddConst(imIn, h, imWrk)
        mamba.dualBuild(imIn, imWrk, grid=grid)
    minima(imWrk, imOut, 1, grid=grid)
Esempio n. 4
0
def minDynamics(imIn, imOut, h, grid=mamba.DEFAULT_GRID):
    """
    Extracts the minima of 'imIn' with a dynamics higher or equal to 'h'
    and puts the result in 'imOut'.
    
    Grid used by the dual build operation can be specified by 'grid'.
    
    Only works with 8-bit or 32-bit images as input. 'imOut' must be binary.
    """
    
    imWrk = mamba.imageMb(imIn)
    if imIn.getDepth() == 8:
        mamba.addConst(imIn, h, imWrk)
        mamba.hierarDualBuild(imIn, imWrk, grid=grid)
        mamba.sub(imWrk, imIn, imWrk)
    else:
        mamba.ceilingAddConst(imIn, h, imWrk)
        mamba.dualBuild(imIn, imWrk, grid=grid)
        mamba.floorSub(imWrk, imIn, imWrk)
    mamba.threshold(imWrk, imOut, h, mamba.computeMaxRange(imIn)[1])
Esempio n. 5
0
def minima(imIn, imOut, h=1, grid=mamba.DEFAULT_GRID):
    """
    Computes the minima of 'imIn' using a dual build operation and puts the 
    result in 'imOut'. When 'h' is equal to 1 (default value), the operator
    provides the minima of 'imIn'.
    
    Grid used by the dual build operation can be specified by 'grid'.
    
    Only works with 8-bit or 32-bit images as input. 'imOut' must be binary.
    """
    
    imWrk = mamba.imageMb(imIn)
    if imIn.getDepth() == 8:
        mamba.addConst(imIn, h, imWrk)
        mamba.hierarDualBuild(imIn, imWrk, grid=grid)
        mamba.sub(imWrk, imIn, imWrk)
    else:
        mamba.ceilingAddConst(imIn, h, imWrk)
        mamba.dualBuild(imIn, imWrk, grid=grid)
        mamba.floorSub(imWrk, imIn, imWrk)
    mamba.threshold(imWrk, imOut, 1, mamba.computeMaxRange(imIn)[1])