Exemple #1
0
    def to_photoimage(self, image_to_show, image_to_seuil):
        if self.seuiling:
            seuilvalue = int(self.scale_seuil_low.get())
        else:
            seuilvalue = 128

        if self.seuilmode:
            image = seuil(image_to_seuil, seuilvalue)
            result = to_photoimage(image)
        elif self.surimpmode:
            bord = border(seuil(image_to_seuil, seuilvalue), 8)
            image = image_to_show
            if self.invertmode:
                image = inverse(image_to_show)
            #inv_bord = inverse(bord)

            image_r = image
            image_g = pink_max(image, bord)
            image_b = pink_max(image, bord)
            result = to_rgb_photoimage([image_r, image_g, image_b])
        else:
            image = image_to_show
            if self.invertmode:
                image = inverse(image_to_show)
            result = to_photoimage(image)

        return result
Exemple #2
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
Exemple #3
0
def extract_cells(image, threshold=24):

    # creating the structuring element
    elem = pink.char_image([3, 3])
    elem.fill(1)
    elem.center = [1, 1]

    grad = pink.gradmorph(muscle, elem)
    seuil = pink.seuil(grad, threshold)
    frame = pink.frame(pink.char_image(image.size), 255)
    dilated = pink.geodilat(frame, seuil, 8)
    skeleton = pink.skeleton(dilated, 0, 8)
    inv = pink.inverse(skeleton)
    eroded = pink.erosball(inv, 5)
    inv = pink.inverse(eroded)
    skeleton2 = pink.skeleton(inv, image, 4)

    return skeleton2
Exemple #4
0
def extract_runways(image, brightness_threshold=23, beed_filter_radius=3):
    seuil = pink.seuil(image, brightness_threshold)
    inv = pink.inverse(seuil)
    asf = pink.asfbin(inv, beed_filter_radius)
    skeleton = pink.skeleton(asf, 0, 8)
    ptcurve = pink.ptcurve(skeleton, 8)
    dilated = pink.geodilat(ptcurve, asf, 8)
    skelcurv = pink.skelcurv(dilated, 0, 8)
    return skelcurv
Exemple #5
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
Exemple #6
0
###
#ex 3.2-2
def remove_touching(image):
    frame = pink.frame(image, 0)
    seeds = image - frame
    #seeds.writeimage("seeds.pgm")
    result = image - pink.geodilat(seeds, image, 8, -1)
    return result


cells_notouch = remove_touching(cells_filt)
viewer1.show(cells_notouch, "cells_notouch")
#cells_nohole.writeimage("cells_nohole.pgm")

#ex 3.3-2
inv = pink.inverse(cells_notouch)
holes = remove_touching(inv)

cells_filled = pink.max(cells_notouch, holes)
viewer1.show(cells_filled, "cells_filled")
#cells_filled.writeimage("cells_filled.pgm")

#ex 3.4-2
objects = pink.geodilat(holes, cells_filled, 8, -1)
cells_final = pink.min(cells_filled, objects)
viewer1.show(cells_final, "cells_final")
#cells_final.writeimage("cells_final.pgm")

#ex 4
## filtering and inverting
circuit = pink.readimage("../images/circuit.pgm")
Exemple #7
0
def fill_the_holes(image):
    frame = pink.frame(pink.char_image(image.size), 255)
    inv = pink.inverse(image)
    dilated = pink.geodilat(frame, inv, 8)
    result = pink.inverse(dilated)
    return result
Exemple #8
0
skelcurv = pink.skelcurv(axonepair, 4, 4)
pink.surimp(axonepair, skelcurv, "imagea.ppm")

skelcurv = pink.skelcurv(axonepair, 8, 8)
pink.surimp(axonepair, skelcurv, "imageb.ppm")

skelcurv = pink.skelcurv(axonepair, 0, 4)
pink.surimp(axonepair, skelcurv, "imagec.ppm")

skelcurv = pink.skelcurv(axonepair, 0, 8)
pink.surimp(axonepair, skelcurv, "imaged.ppm")

### 3D curvilinear skeleton
skelcurv = pink.skelcurv(lettre_a, 6, 6)
if debug:
    render(lettre_a, pink.inverse(skelcurv))

### curvilinear skeleton of the carotide
skelcurv = pink.skelcurv(carotide_seg, 0, 26)
if debug:
    render(skelcurv, skelcurv)
# we can see, that there's a cavity and a cycle in the skeleton
closed = pink.closeball(carotide_seg, 1)
skelcurv = pink.skelcurv(closed, 0, 26)
#if debug: # cde package generation

render(skelcurv)
# now we eliminate the border points
skelcurv = skelcurv - pink.frame(pink.char_image(skelcurv.size), 255)
if debug:
    render(skelcurv)