コード例 #1
0
def contrastEnhancer(imIn, imOut, n=1, se=mamba.DEFAULT_SE):
    """
    Increase the contrast of image 'imIn' and put the result in
    image 'imOut'. Parameter 'n' will control the size and 'se' the
    structuring element used by the top hat operators.
    """

    imWrk = mamba.imageMb(imIn)
    mamba.whiteTopHat(imIn, imWrk, n, se=se)
    mamba.add(imIn, imWrk, imOut)
    mamba.blackTopHat(imIn, imWrk, n, se=se)
    mamba.sub(imOut, imWrk, imOut) 
コード例 #2
0
ファイル: script.py プロジェクト: nicolasBeucher/mamba-image
        d = i + 1
        linearUltimateOpen(imIn, imWrk2, d, grid=grid)
        mamba.generateSupMask(imWrk2, imWrk1, imWrk3, True)
        mamba.logic(imWrk2, imWrk1, imWrk1, "sup")
        mamba.convertByMask(imWrk3, imWrk4, 0, d)
        mamba.logic(imWrk4, imOut, imOut, "sup")       

# Trying these operators on a fiber image.
# Loading the initial image.
im1 = mamba.imageMb('fiber.png')
# Defining some working images.
im2 = mamba.imageMb(im1)
imbin1 = mamba.imageMb(im1, 1)
# A binary image is defined by a top-hat operator, followed by
# a thresholding and a filtering.
mamba.blackTopHat(im1, im2, 10)
mamba.threshold(im2, imbin1, 50, 255)
mamba.buildClose(imbin1, imbin1, 2)
# The directions encoding is performed.
directionalCoding(imbin1, im2)
# A palette for displaying the 6 possible directions is defined.
dirpal = (0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255)
for i in range(249):
    dirpal = dirpal + (0, 0, 0)
# The result is saved with the palette.
im2.save('coded_directions.png', palette=dirpal)



    
コード例 #3
0
ファイル: script.py プロジェクト: nicolasBeucher/mamba-image
    imWrk1.reset()
    for i in range(mamba.gridNeighbors(grid=grid)):
        d = i + 1
        linearUltimateOpen(imIn, imWrk2, d, grid=grid)
        mamba.generateSupMask(imWrk2, imWrk1, imWrk3, True)
        mamba.logic(imWrk2, imWrk1, imWrk1, "sup")
        mamba.convertByMask(imWrk3, imWrk4, 0, d)
        mamba.logic(imWrk4, imOut, imOut, "sup")


# Trying these operators on a fiber image.
# Loading the initial image.
im1 = mamba.imageMb('fiber.png')
# Defining some working images.
im2 = mamba.imageMb(im1)
imbin1 = mamba.imageMb(im1, 1)
# A binary image is defined by a top-hat operator, followed by
# a thresholding and a filtering.
mamba.blackTopHat(im1, im2, 10)
mamba.threshold(im2, imbin1, 50, 255)
mamba.buildClose(imbin1, imbin1, 2)
# The directions encoding is performed.
directionalCoding(imbin1, im2)
# A palette for displaying the 6 possible directions is defined.
dirpal = (0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255,
          255, 0, 255)
for i in range(249):
    dirpal = dirpal + (0, 0, 0)
# The result is saved with the palette.
im2.save('coded_directions.png', palette=dirpal)