示例#1
0
# associated to a preliminary selection of the zone where these teeth should be.

## SCRIPT ######################################################################
# Importing mamba
import mamba
import mambaDisplay

im = mamba.imageMb("wheel.png", 1)
im1 = mamba.imageMb(im, 1)
im2 = mamba.imageMb(im, 1)

# Opening of image
mamba.opening(im, im1, 3)
# Selection of the outside region
mamba.negate(im1, im2)
mamba.removeEdgeParticles(im2, im1)
mamba.diff(im2, im1, im2)
# Extracting the wheel teeth
mamba.logic(im, im2, im2, "inf")
# Cleaning the image
mamba.opening(im2, im2)
# Counting and marking each tooth
mamba.thinD(im2, im1)
nb_teeth = mamba.computeVolume(im1)
print("Number of teeth: %d" % (nb_teeth))
mamba.dilate(im1, im1, 3, mamba.SQUARE3X3)
im1.convert(8)
im8 = mamba.imageMb(im, 8)
mamba.convert(im, im8)
mamba.subConst(im8, 1, im8)
mamba.logic(im8, im1, im8, "sup")
示例#2
0
    if edge == mamba.EMPTY:
        mamba.copy(imIn, imWrk)
    directionalDilate(imIn, imOut, d, size, grid=grid, edge=edge)
    j = (d + mamba.gridNeighbors(grid=grid) -
         1) % (mamba.gridNeighbors(grid=grid) * 2) + 1
    directionalErode(imOut, imOut, j, size, grid=grid)
    if edge == mamba.EMPTY:
        mamba.logic(imOut, imWrk, imOut, "sup")


# Trying these operators on a fibers image.
# Loading the initial image.
im1 = mamba.imageMb('ferrite.png')
# Defining some working images.
im2 = mamba.imageMb(im1)
imbin1 = mamba.imageMb(im1, 1)
# Performing a directional opening of size 30 in direction 6.
# This should select fibers with a length greater than 60 in
# direction 165 degrees approximately (a square grid is used).
directionalOpen(im1, im2, 6, 30, grid=mamba.SQUARE)
# The markers (obtained by a simple threshold) of the corresponding
# fibers are superposed to the original image (some filtering is
# performed by removing fibers cutting the edges).
mamba.threshold(im2, imbin1, 100, 255)
mamba.removeEdgeParticles(imbin1, imbin1)
# The same operation is performed once again on the thresholded
# image to verify the markers sizes.
directionalOpen(imbin1, imbin1, 6, 30, grid=mamba.SQUARE)
# displaying the result.
mE.superpose(im1, imbin1)
示例#3
0
    
    imWrk = mamba.imageMb(imIn)
    if edge==mamba.EMPTY:
        mamba.copy(imIn, imWrk)
    directionalDilate(imIn, imOut, d, size, grid=grid, edge=edge)
    j = (d + mamba.gridNeighbors(grid=grid) - 1) % (mamba.gridNeighbors(grid=grid) * 2) + 1
    directionalErode(imOut, imOut, j, size, grid=grid)
    if edge==mamba.EMPTY:
        mamba.logic(imOut, imWrk, imOut, "sup")

# Trying these operators on a fibers image.
# Loading the initial image.
im1 = mamba.imageMb('ferrite.png')
# Defining some working images.
im2 = mamba.imageMb(im1)
imbin1 = mamba.imageMb(im1, 1)
# Performing a directional opening of size 30 in direction 6.
# This should select fibers with a length greater than 60 in
# direction 165 degrees approximately (a square grid is used).
directionalOpen(im1, im2, 6, 30, grid=mamba.SQUARE)
# The markers (obtained by a simple threshold) of the corresponding
# fibers are superposed to the original image (some filtering is
# performed by removing fibers cutting the edges).
mamba.threshold(im2, imbin1, 100, 255)
mamba.removeEdgeParticles(imbin1, imbin1)
# The same operation is performed once again on the thresholded
# image to verify the markers sizes.
directionalOpen(imbin1, imbin1, 6, 30, grid=mamba.SQUARE)
# displaying the result.
mE.superpose(im1, imbin1)
示例#4
0
# associated to a preliminary selection of the zone where these teeth should be.

## SCRIPT ######################################################################
# Importing mamba
import mamba
import mambaDisplay

im = mamba.imageMb("wheel.png", 1)
im1 = mamba.imageMb(im, 1)
im2 = mamba.imageMb(im, 1)

# Opening of image
mamba.opening(im, im1, 3)
# Selection of the outside region
mamba.negate(im1, im2)
mamba.removeEdgeParticles(im2, im1)
mamba.diff(im2, im1, im2)
# Extracting the wheel teeth
mamba.logic(im, im2, im2, "inf")
# Cleaning the image
mamba.opening(im2, im2)
# Counting and marking each tooth
mamba.thinD(im2, im1)
nb_teeth = mamba.computeVolume(im1)
print("Number of teeth: %d" % (nb_teeth))
mamba.dilate(im1, im1, 3, mamba.SQUARE3X3)
im1.convert(8)
im8 = mamba.imageMb(im, 8)
mamba.convert(im, im8)
mamba.subConst(im8, 1, im8)
mamba.logic(im8, im1, im8, "sup")