예제 #1
0
def ceilingAddConst3D(imIn, v, imOut):
    """
    Adds a constant value 'v' to image 'imIn' and puts the result in 'imOut'. If
    imIn + v is larger than the maximal possible value in imOut, the result is
    truncated and limited to this maximal value.
    
    Note that this operator is mainly useful for 32-bit images, as the result
    of the addition is always truncated for 8-bit images.
    """
    outl = len(imOut)
    inl = len(imIn)
    if inl!=outl:
        mamba.raiseExceptionOnError(core.MB_ERR_BAD_SIZE)
    
    for i in range(outl):
        mamba.ceilingAddConst(imIn[i], v, imOut[i])
예제 #2
0
def ceilingAddConst3D(imIn, v, imOut):
    """
    Adds a constant value 'v' to image 'imIn' and puts the result in 'imOut'. If
    imIn + v is larger than the maximal possible value in imOut, the result is
    truncated and limited to this maximal value.
    
    Note that this operator is mainly useful for 32-bit images, as the result
    of the addition is always truncated for 8-bit images.
    """
    outl = len(imOut)
    inl = len(imIn)
    if inl != outl:
        mamba.raiseExceptionOnError(core.MB_ERR_BAD_SIZE)

    for i in range(outl):
        mamba.ceilingAddConst(imIn[i], v, imOut[i])
예제 #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)
예제 #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])
예제 #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])