Beispiel #1
0
    """
    Top-hat operator applied on image 'imIn' obtained by a supremum of linear
    openings of size 'size' and a reconstruction. The result is put in 'imOut'.
    This operator extracts white objects with a thickness less than 2*'size'
    in all directions.
    """
    imWrk = imageMb(imIn)
    supOpen(imIn, imWrk, size)
    build(imIn, imWrk)
    sub(imIn, imWrk, imOut)


# Reading the initial image.
imIn = imageMb('retina.png')

# Working image and result image.
imWrk = imageMb(imIn)
aneurisms = imageMb(imIn, 1)

# Extraction of aneurisms.
buildSupWhiteTopHat(imIn, imWrk, 10)
# Thresholding of the image (the value of the threshold is half the maximum
# grey value in the top-hat image.
t = computeRange(imWrk)[1] / 2
threshold(imWrk, aneurisms, t, 255)

# Superposing the result to the original image and saving the result.
multiSuperpose(imIn, aneurisms)
name = mambaDisplay.tagOneColorPalette(255, (255, 0, 0))
imIn.save('aneurisms.png', palette=mambaDisplay.getPalette(name))
Beispiel #2
0
    v = computeMaxRange3D(imOut)[1]
    imOut.setPixel(v, (w / 2, h / 2, l / 2))

    ses = []
    for d in directions:
        ses.append(structuringElement3D([0, d], grid))

    for i in range(n):
        for se in ses:
            dilate3D(imOut, imOut, 1, se=se)
    imOut.update()


im3D = image3DMb()
im3D.show()
mambaDisplay.tagOneColorPalette(255, (255, 150, 0))
# We will choose orange to display the polyhedron. hit p to select
# the newly created palette.
# At this point, it is worth signaling that the result will look
# better in volume rendering (F2) using the isosurface process
# (Use <Tab> on the display to modify it).

# Drawing a rhombododecahedron
steiner3D(im3D, 30, [11, 15, 22, 26], CUBIC)
# If you look at the display after this step you will see
# a strange blur. It is because the directions does not allow to fill all
# the space so we close the 1 pixel gaps with CUBE3X3X3
closing3D(im3D, im3D, 1, CUBE3X3X3)
im3D.update()
Beispiel #3
0
# 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")
name = mambaDisplay.tagOneColorPalette(255, (0,0,255))
im8.save('wheel_teeth.png', palette=mambaDisplay.getPalette(name))
Beispiel #4
0
        # was below the target volume
        level -= 2*inc
        # Decreasing increment for better precision
        inc = inc/10
    
    copy(imWrk1, imFlood)
    return (level+2, vol)

imDEM = imageMb("NED10Meter.tif")
imFlood = imageMb(imDEM)

# Our flood starting point
imFlood.setPixel(255, (1337,81))

# Computing the flood area, level and actual volume needed to reach
# it with a control volume of 20000000. This is not of course a 'real'
# volume but you can compute its actual physical meaning if you have all
# the information regarding your DEM (such as grid resolution and pixel
# value metrics). Here we picked a SQUARE grid because it is most
# likely going to represent the grid used in the DEM.
print(volumeControlledFlood(imDEM, imFlood, 20000000, grid=SQUARE))

# Displaying the result
imDEM_8 = imageMb(imDEM, 8)
imFlood_8 = imageMb(imDEM, 8)
downscale(imDEM,imDEM_8)
copyBytePlane(imFlood, 0, imFlood_8)
logic(imDEM_8, imFlood_8, imDEM_8, "sup")
name = mambaDisplay.tagOneColorPalette(255,(0,100,255))
imDEM_8.save("flood.png", palette=mambaDisplay.getPalette(name))