コード例 #1
0
def buildClose3D(imIn, imOut, n=1, se=m3D.CUBOCTAHEDRON1):
    """
    Performs a closing by dual reconstruction operation on 3D image 'imIn'
    and puts the result in 'imOut'. 'n' controls the size of the closing.
    """

    imWrk = m3D.image3DMb(imIn)
    m3D.copy3D(imIn, imWrk)
    m3D.dilate3D(imIn, imOut, n, se=se)
    m3D.dualBuild3D(imWrk, imOut, grid=se.getGrid())
コード例 #2
0
def buildClose3D(imIn, imOut, n=1, se=m3D.CUBOCTAHEDRON1):
    """
    Performs a closing by dual reconstruction operation on 3D image 'imIn'
    and puts the result in 'imOut'. 'n' controls the size of the closing.
    """

    imWrk = m3D.image3DMb(imIn)
    m3D.copy3D(imIn, imWrk)
    m3D.dilate3D(imIn, imOut, n, se=se)
    m3D.dualBuild3D(imWrk, imOut, grid=se.getGrid())
コード例 #3
0
def minPartialBuild3D(imIn, imMask, imOut, grid=m3D.DEFAULT_GRID3D):
    """
    Performs the partial reconstruction of 'imIn' with its minima which are
    contained in the binary mask 'imMask'. The result is put in 'imOut'.
    
    'imIn' and 'imOut' must be different and greyscale images.
    """
    
    imWrk = m3D.image3DMb(imIn, 1)
    minima3D(imIn, imWrk, 1, grid=grid)
    m3D.logic3D(imMask, imWrk, imWrk, "inf")
    m3D.convertByMask3D(imWrk, imOut, mamba.computeMaxRange(imIn[0])[1], 0)
    m3D.logic3D(imIn, imOut, imOut, "sup")
    m3D.dualBuild3D(imIn, imOut)
コード例 #4
0
def minPartialBuild3D(imIn, imMask, imOut, grid=m3D.DEFAULT_GRID3D):
    """
    Performs the partial reconstruction of 'imIn' with its minima which are
    contained in the binary mask 'imMask'. The result is put in 'imOut'.
    
    'imIn' and 'imOut' must be different and greyscale images.
    """

    imWrk = m3D.image3DMb(imIn, 1)
    minima3D(imIn, imWrk, 1, grid=grid)
    m3D.logic3D(imMask, imWrk, imWrk, "inf")
    m3D.convertByMask3D(imWrk, imOut, mamba.computeMaxRange(imIn[0])[1], 0)
    m3D.logic3D(imIn, imOut, imOut, "sup")
    m3D.dualBuild3D(imIn, imOut)
コード例 #5
0
def minima3D(imIn, imOut, h=1, grid=m3D.DEFAULT_GRID3D):
    """
    Computes the minima of 'imIn' using a dual build operation and puts the 
    result in 'imOut'.
    
    'h' can be used to define the minima depth. Grid used by the dual build 
    operation can be specified by 'grid'.
    
    Only works with 8-bit or 32-bit as input. 'imOut' must be binary.
    """
    
    imWrk = m3D.image3DMb(imIn)
    m3D.addConst3D(imIn, h, imWrk)
    m3D.dualBuild3D(imIn, imWrk, grid=grid)
    m3D.sub3D(imWrk, imIn, imWrk)
    m3D.threshold3D(imWrk, imOut, 1, mamba.computeMaxRange(imIn[0])[1])
コード例 #6
0
def minima3D(imIn, imOut, h=1, grid=m3D.DEFAULT_GRID3D):
    """
    Computes the minima of 'imIn' using a dual build operation and puts the 
    result in 'imOut'.
    
    'h' can be used to define the minima depth. Grid used by the dual build 
    operation can be specified by 'grid'.
    
    Only works with 8-bit or 32-bit as input. 'imOut' must be binary.
    """

    imWrk = m3D.image3DMb(imIn)
    m3D.addConst3D(imIn, h, imWrk)
    m3D.dualBuild3D(imIn, imWrk, grid=grid)
    m3D.sub3D(imWrk, imIn, imWrk)
    m3D.threshold3D(imWrk, imOut, 1, mamba.computeMaxRange(imIn[0])[1])
コード例 #7
0
def deepMinima3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    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 = m3D.image3DMb(imIn)
    if imIn.getDepth() == 8:
        m3D.addConst3D(imIn, h, imWrk)
    else:
        m3D.ceilingAddConst3D(imIn, h, imWrk)
    m3D.dualBuild3D(imIn, imWrk, grid=grid)
    minima3D(imWrk, imOut, 1, grid=grid)
コード例 #8
0
def deepMinima3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    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 = m3D.image3DMb(imIn)
    if imIn.getDepth() == 8:
        m3D.addConst3D(imIn, h, imWrk)
    else:
        m3D.ceilingAddConst3D(imIn, h, imWrk)
    m3D.dualBuild3D(imIn, imWrk, grid=grid)
    minima3D(imWrk, imOut, 1, grid=grid)
コード例 #9
0
def minDynamics3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    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 = m3D.image3DMb(imIn)
    if imIn.getDepth() == 8:
        m3D.addConst3D(imIn, h, imWrk)
        m3D.dualBuild3D(imIn, imWrk, grid=grid)
        m3D.sub3D(imWrk, imIn, imWrk)
    else:
        m3D.ceilingAddConst3D(imIn, h, imWrk)
        m3D.dualBuild3D(imIn, imWrk, grid=grid)
        m3D.floorSub3D(imWrk, imIn, imWrk)
    m3D.threshold3D(imWrk, imOut, h, mamba.computeMaxRange(imIn[0])[1])
コード例 #10
0
def minDynamics3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    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 = m3D.image3DMb(imIn)
    if imIn.getDepth() == 8:
        m3D.addConst3D(imIn, h, imWrk)
        m3D.dualBuild3D(imIn, imWrk, grid=grid)
        m3D.sub3D(imWrk, imIn, imWrk)
    else:
        m3D.ceilingAddConst3D(imIn, h, imWrk)
        m3D.dualBuild3D(imIn, imWrk, grid=grid)
        m3D.floorSub3D(imWrk, imIn, imWrk)
    m3D.threshold3D(imWrk, imOut, h, mamba.computeMaxRange(imIn[0])[1])
コード例 #11
0
def simpleLevelling3D(imIn, imMask, imOut, grid=m3D.DEFAULT_GRID3D):
    """
    Performs a simple levelling of 3D image 'imIn' controlled by image 'imMask'
    and puts the result in 'imOut'. This operation is composed of two
    geodesic reconstructions. This filter tends to level regions in the 
    image of homogeneous grey values.
    """

    imWrk1 = m3D.image3DMb(imIn)
    imWrk2 = m3D.image3DMb(imIn)
    mask_im = m3D.image3DMb(imIn, 1)
    m3D.logic3D(imIn, imMask, imWrk1, "inf")
    m3D.build3D(imIn, imWrk1, grid=grid)
    m3D.logic3D(imIn, imMask, imWrk2, "sup")
    m3D.dualBuild3D(imIn, imWrk2, grid=grid)
    m3D.generateSupMask3D(imIn, imMask, mask_im, False)
    m3D.convertByMask3D(mask_im, imOut, 0, m3D.computeMaxRange3D(imIn)[1])
    m3D.logic3D(imOut, imWrk1, imWrk1, "inf")
    m3D.negate3D(imOut, imOut)
    m3D.logic3D(imOut, imWrk2, imOut, "inf")
    m3D.logic3D(imWrk1, imOut, imOut, "sup")
コード例 #12
0
def simpleLevelling3D(imIn, imMask, imOut, grid=m3D.DEFAULT_GRID3D):
    """
    Performs a simple levelling of 3D image 'imIn' controlled by image 'imMask'
    and puts the result in 'imOut'. This operation is composed of two
    geodesic reconstructions. This filter tends to level regions in the 
    image of homogeneous grey values.
    """
    
    imWrk1 = m3D.image3DMb(imIn)
    imWrk2 = m3D.image3DMb(imIn)
    mask_im = m3D.image3DMb(imIn, 1)
    m3D.logic3D(imIn, imMask, imWrk1, "inf")
    m3D.build3D(imIn, imWrk1, grid=grid)
    m3D.logic3D(imIn, imMask, imWrk2, "sup")
    m3D.dualBuild3D(imIn, imWrk2, grid=grid)
    m3D.generateSupMask3D(imIn, imMask, mask_im, False)
    m3D.convertByMask3D(mask_im, imOut, 0, m3D.computeMaxRange3D(imIn)[1])
    m3D.logic3D(imOut, imWrk1, imWrk1, "inf")
    m3D.negate3D(imOut, imOut)
    m3D.logic3D(imOut, imWrk2, imOut, "inf")
    m3D.logic3D(imWrk1, imOut, imOut, "sup")
コード例 #13
0
def strongLevelling3D(imIn, imOut, n, eroFirst, grid=m3D.DEFAULT_GRID3D):
    """
    Strong levelling of 'imIn', result in 'imOut'. 'n' defines the size of the
    erosion and dilation of 'imIn' in the operation. If 'eroFirst' is true, the
    operation starts with an erosion, it starts with a dilation otherwise.
    
    This filter is stronger (more efficient) that simpleLevelling3D. However, the
    order of the initial operations (erosion and dilation) matters.
    """

    imWrk = m3D.image3DMb(imIn)
    se = m3D.structuringElement3D(m3D.getDirections3D(grid), grid)
    if eroFirst:
        m3D.erode3D(imIn, imWrk, n, se=se)
        m3D.build3D(imIn, imWrk, grid=grid)
        m3D.dilate3D(imIn, imOut, n, se=se)
        m3D.dualBuild3D(imWrk, imOut, grid=grid)
    else:
        m3D.dilate3D(imIn, imWrk, n, se=se)
        m3D.dualBuild3D(imIn, imWrk, grid=grid)
        m3D.erode3D(imIn, imOut, n, se=se)
        m3D.build3D(imWrk, imOut, grid=grid)
コード例 #14
0
def strongLevelling3D(imIn, imOut, n, eroFirst, grid=m3D.DEFAULT_GRID3D):
    """
    Strong levelling of 'imIn', result in 'imOut'. 'n' defines the size of the
    erosion and dilation of 'imIn' in the operation. If 'eroFirst' is true, the
    operation starts with an erosion, it starts with a dilation otherwise.
    
    This filter is stronger (more efficient) that simpleLevelling3D. However, the
    order of the initial operations (erosion and dilation) matters.
    """
    
    imWrk = m3D.image3DMb(imIn)
    se = m3D.structuringElement3D(m3D.getDirections3D(grid), grid)
    if eroFirst:
        m3D.erode3D(imIn, imWrk, n, se=se)
        m3D.build3D(imIn, imWrk, grid=grid)
        m3D.dilate3D(imIn, imOut, n, se=se)
        m3D.dualBuild3D(imWrk, imOut, grid=grid)
    else:
        m3D.dilate3D(imIn, imWrk, n, se=se)
        m3D.dualBuild3D(imIn, imWrk, grid=grid)
        m3D.erode3D(imIn, imOut, n, se=se)
        m3D.build3D(imWrk, imOut, grid=grid)