Example #1
0
def mosaic3D(imIn, imOut, imWts, grid=m3D.DEFAULT_GRID3D):
    """
    Builds the mosaic 3D image of 'imIn' and puts the results into 'imOut'.
    The watershed line (pixel values set to 255) is stored in the 
    greytone 3D image 'imWts'. A mosaic image is a simple image made of various 
    tiles of uniform grey values. It is built using the watershed of 'imIn' 
    gradient and original markers made of gradient minima which are labelled by
    the maximum value of 'imIn' pixels inside them.
    """

    imWrk1 = m3D.image3DMb(imIn, 1)
    imWrk2 = m3D.image3DMb(imIn)
    m3D.copy3D(imIn, imWrk2)
    im_mark = m3D.image3DMb(imIn, 32)
    se = m3D.structuringElement3D(m3D.getDirections3D(grid), grid)
    m3D.gradient3D(imIn, imOut, se=se)
    m3D.minima3D(imOut, imWrk1, grid=grid)
    m3D.add3D(im_mark, imWrk1, im_mark)
    imWrk1.convert(8)
    m3D.build3D(imWrk1, imWrk2, grid=grid)
    m3D.add3D(im_mark, imWrk2, im_mark)
    m3D.watershedSegment3D(imOut, im_mark, grid=grid)
    m3D.copyBytePlane3D(im_mark, 3, imWts)
    m3D.subConst3D(im_mark, 1, im_mark)
    m3D.copyBytePlane3D(im_mark, 0, imOut)
Example #2
0
def mosaic3D(imIn, imOut, imWts, grid=m3D.DEFAULT_GRID3D):
    """
    Builds the mosaic 3D image of 'imIn' and puts the results into 'imOut'.
    The watershed line (pixel values set to 255) is stored in the 
    greytone 3D image 'imWts'. A mosaic image is a simple image made of various 
    tiles of uniform grey values. It is built using the watershed of 'imIn' 
    gradient and original markers made of gradient minima which are labelled by
    the maximum value of 'imIn' pixels inside them.
    """
   
    imWrk1 = m3D.image3DMb(imIn, 1)
    imWrk2 = m3D.image3DMb(imIn)
    m3D.copy3D(imIn, imWrk2)
    im_mark = m3D.image3DMb(imIn, 32)
    se = m3D.structuringElement3D(m3D.getDirections3D(grid), grid)
    m3D.gradient3D(imIn, imOut, se=se)
    m3D.minima3D(imOut, imWrk1, grid=grid) 
    m3D.add3D(im_mark, imWrk1, im_mark) 
    imWrk1.convert(8)
    m3D.build3D(imWrk1, imWrk2, grid=grid)
    m3D.add3D(im_mark, imWrk2, im_mark)   
    m3D.watershedSegment3D(imOut, im_mark, grid=grid)
    m3D.copyBytePlane3D(im_mark, 3, imWts)
    m3D.subConst3D(im_mark, 1, im_mark)
    m3D.copyBytePlane3D(im_mark, 0, imOut)
Example #3
0
def maxima3D(imIn, imOut, h=1, grid=m3D.DEFAULT_GRID3D):
    """
    Computes the maxima of 'imIn' using a build operation and puts the
    result in 'imOut'.
    
    'h' can be used to define the maxima height. Grid used by the 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.subConst3D(imIn, h, imWrk)
    m3D.build3D(imIn, imWrk, grid=grid)
    m3D.sub3D(imIn, imWrk, imWrk)
    m3D.threshold3D(imWrk, imOut, 1, mamba.computeMaxRange(imIn[0])[1])
Example #4
0
def maxima3D(imIn, imOut, h=1, grid=m3D.DEFAULT_GRID3D):
    """
    Computes the maxima of 'imIn' using a build operation and puts the
    result in 'imOut'.
    
    'h' can be used to define the maxima height. Grid used by the 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.subConst3D(imIn, h, imWrk)
    m3D.build3D(imIn, imWrk, grid=grid)
    m3D.sub3D(imIn, imWrk, imWrk)
    m3D.threshold3D(imWrk, imOut, 1, mamba.computeMaxRange(imIn[0])[1])
Example #5
0
def highMaxima3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    Computes the maxima of the reconstruction of image 'imIn' by imIn - h
    and puts the result in 'imOut'.

    Grid used by the 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.subConst3D(imIn, h, imWrk)
    else:
        m3D.floorSubConst3D(imIn, h, imWrk)
    m3D.build3D(imIn, imWrk, grid=grid)
    m3D.maxima3D(imWrk, imOut, 1, grid=grid)
Example #6
0
def highMaxima3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    Computes the maxima of the reconstruction of image 'imIn' by imIn - h
    and puts the result in 'imOut'.

    Grid used by the 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.subConst3D(imIn, h, imWrk)
    else:
        m3D.floorSubConst3D(imIn, h, imWrk)
    m3D.build3D(imIn, imWrk, grid=grid)
    m3D.maxima3D(imWrk, imOut, 1, grid=grid)
Example #7
0
def maxDynamics3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    Extracts the maxima 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.subConst3D(imIn, h, imWrk)
        m3D.build3D(imIn, imWrk, grid=grid)
        m3D.sub3D(imIn, imWrk, imWrk)
    else:
        m3D.floorSubConst3D(imIn, h, imWrk)
        m3D.build3D(imIn, imWrk, grid=grid)
        m3D.floorSub3D(imIn, imWrk, imWrk)
    m3D.threshold3D(imWrk, imOut, h, mamba.computeMaxRange(imIn[0])[1])
Example #8
0
def maxDynamics3D(imIn, imOut, h, grid=m3D.DEFAULT_GRID3D):
    """
    Extracts the maxima 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.subConst3D(imIn, h, imWrk)
        m3D.build3D(imIn, imWrk, grid=grid)
        m3D.sub3D(imIn, imWrk, imWrk)
    else:
        m3D.floorSubConst3D(imIn, h, imWrk)
        m3D.build3D(imIn, imWrk, grid=grid)
        m3D.floorSub3D(imIn, imWrk, imWrk)
    m3D.threshold3D(imWrk, imOut, h, mamba.computeMaxRange(imIn[0])[1])