Ejemplo n.º 1
0
def disk_structuring_element(radius):
    d = radius + radius + 1
    res = pink.char_image([d, d])
    res.fill(0)
    res.center = [radius, radius]
    res[[radius, radius]] = 255
    res = pink.dilatball(res, radius)
    return (res)
Ejemplo n.º 2
0
def extract_corne(image, threshold):
    seuil = pink.seuil(image, threshold, 0, 255)
    opened = pink.openball(seuil, 3)
    geodilat = pink.geodilat(opened, seuil, 8)
    diff = seuil - geodilat
    dilated = pink.dilatball(diff, 4)
    opened2 = pink.openball(dilated, 10)
    geodilat2 = pink.geodilat(opened2, dilated, 8)
    closed = pink.closeball(geodilat2, 4)
    border = pink.border(closed, 8)
    return border
Ejemplo n.º 3
0
def extract_fractures(image):
    seuil = pink.seuil(image, 123)
    inv = pink.inverse(seuil)
    skeleton1 = pink.skelcurv(inv, 0, 8)
    endpoints = pink.ptend(skeleton1, 8)
    dilated = pink.dilatball(endpoints, 1, 8)
    sub = skeleton1 - dilated
    add = endpoints + sub
    inv = pink.inverse(add)
    skeleton2 = pink.skeleton(inv, 0, 4)
    inv = pink.inverse(skeleton2)
    dilated = pink.geodilat(endpoints, inv, 4)
    return dilated
Ejemplo n.º 4
0
def find_the_wires(image, seuil):
    # binarize
    binary = pink.seuil(image, seuil, 0, 255)
    inv = pink.inverse(binary)

    # eliminate the little objects
    #filtered = filter(inv, 2, 8)
    eros = pink.erosball(inv, 2)
    filtered = pink.geodilat(eros, inv, 8)

    # fill the holes
    filled = fill_the_holes(filtered)

    # detect the joints
    eros = pink.erosball(filled, 6)
    dilat = pink.dilatball(eros, 6)
    joints = pink.geodilat(dilat, filled, 8, 1)

    # extract the wires
    result = filled - joints

    return result
Ejemplo n.º 5
0
def filter_noise(image):
    eroded = pink.erosball(image, 1, 0)
    recons1 = pink.geodilat(eroded, image, 8, 10)
    dilated = pink.dilatball(recons1, 2, 0)
    result = pink.geoeros(dilated, recons1, 8, 10)
    return result
Ejemplo n.º 6
0
#ex 3.1-2
I = pink.readimage("../images/cells.pgm")

viewer1 = Imview(I)

eroded = pink.erosball(I, 1, 0)
viewer1.show(eroded, "eroded")  # spacebar to switch from one image to the next

#ex 3.1-3
recons1 = pink.geodilat(eroded, I, 8, 10)
viewer1.show(recons1, "recons1")
#recons1.writeimage("recons1.pgm")

#ex 3.1-4
# we start from the already partially denoised result
dilated = pink.dilatball(recons1, 1, 0)
recons2 = pink.geoeros(dilated, recons1, 8, 10)

# we save this result
#recons2.writeimage("recons2.pgm")

#ex 3.1-5


# a procedure to do everything as a function
def filter_noise(image):
    eroded = pink.erosball(image, 1, 0)
    recons1 = pink.geodilat(eroded, image, 8, 10)
    dilated = pink.dilatball(recons1, 2, 0)
    result = pink.geoeros(dilated, recons1, 8, 10)
    return result
Ejemplo n.º 7
0
def filter(image, radius_opening, radius_closing):
    eroded = pink.erosball(image, radius_opening)
    recons1 = pink.geodilat(eroded, image, 8)
    dilated = pink.dilatball(recons1, radius_closing)
    result = pink.geoeros(dilated, recons1, 8)
    return result
Ejemplo n.º 8
0
debug = True
# ## uncomment to perform the debug operations
# debug=True

lettre_a = pink.readimage("../images/lettre_a.pgm")
carotide = pink.readimage("../images/carotide.pgm")

if debug:
    view3d(lettre_a)
if debug:
    view3d(carotide)
#seuilmesh(carotide)

seuil = pink.seuil(carotide, 105)
dilated = pink.dilatball(seuil, 2)
if debug:
    view3d(carotide, dilated)
diff = carotide - dilated

seuil = pink.seuil(diff, 94)
if debug:
    view3d(carotide, seuil)
component = pink.selectcomp(seuil, 26, 58, 46, 0)
if debug:
    view3d(carotide, component)
carotide_seg = component

###  the skeleton operator
axonepair = pink.readimage("../images/axonepair.pgm")
#imview(axonepair) ## HUGUES WRITE ME!
Ejemplo n.º 9
0
    cs = image.size[1]
    for j in range(margin, cs-margin):
        for i in range(margin, rs-margin):
            if random.random() <= p:
                image[[i,j]] = 255

rad = 4 # radius of particles
RS = 4 # numbers of tiles in a row
CS = 4 # numbers of tiles in a column
rs = 100 # row size for a tile
cs = 100 # column size for a tile
pr = 0.0004 # proportion of particle centers

img = pink.char_image([RS*rs,CS*cs])
randimage2(img, pr, rad+1)
img = pink.dilatball(img, rad)
img.writeimage("wholeimage.pgm")
imview(img)

grain_size = pink.area(img)
lab = pink.labelfgd(img, 8)
nb_grains = pink.minmax(lab)[1]

print("grain_size = " + str(grain_size))
print("nb_grains = " + str(nb_grains))

img = pink.readimage("wholeimage.pgm")
tile = pink.char_image([rs,cs])
for J in range(CS):
    for I in range(RS):
        filename = 'tile%02d.pgm'%(J*CS+I)
Ejemplo n.º 10
0
def try_dilation(radius):
    return pink.dilatball(IMAGE, radius)