Example #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
Example #2
0
def analyzejoints(image, seg):
    # extracts thin pores
    ball = pink.genball(3)

    # The following line is the definition of closing, so it can be
    # replaced by a single operator
    #tophat = pink.erosion(pink.dilation(image, ball), ball) - image
    tophat = pink.closing(image, ball) - image

    if debug:
        tophat.writeimage("_tophat")
    thinpores = pink.seuil(tophat, 17)
    if debug:
        thinpores.writeimage("_thinpores")
    # extracts thin pores
    black = inv(pink.seuil(image, 150))
    thickpores = pink.segmentarea(black, 4, 100, 0)
    thickpores = pink.dilation(thickpores, pink.genball(1))
    if debug:
        thickpores.writeimage("_thickpores")
    # extracts joints
    joint = seg - thickpores
    if debug:
        joint.writeimage("_joint")
    jointlen = pink.area(joint)
    print("longueur totale des joints : " + str(jointlen))
    # extracts coroded parts of joints
    corojoint = pink.min(pink.dilation(thinpores, pink.genball(1)), joint)
    if debug:
        corojoint.writeimage("_corojoint")
        pink.surimp(joint, corojoint, "_res")
    corojointlen = pink.area(corojoint)
    print("longueur des joints corrodes : " + str(corojointlen))

    return (corojoint)
Example #3
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
Example #4
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
Example #5
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
Example #6
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
Example #7
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
Example #8
0
def carbide_detection(image, rad_bth, seuil, rad_op):
    es = disk_structuring_element(rad_bth)
    if DEBUG:
        imview(es)
        raw_input("press enter to continue...")
        es.writeimage("_es")
    bth = black_top_hat(image, es)
    if DEBUG:
        imview(bth)
        raw_input("press enter to continue...")
        bth.writeimage("_bth")
    thr = pink.seuil(bth, seuil)
    if DEBUG:
        imview(thr)
        raw_input("press enter to continue...")
        thr.writeimage("_thr")
    opb = pink.openball(thr, rad_op)
    if DEBUG:
        imview(opb)
        raw_input("press enter to continue...")
        opb.writeimage("_opb")
    res = pink.attribute(opb, 8, 0, 0, 0)
    return res
Example #9
0
def try_DLMA(la):
    dlma = pink.lambdamedialaxis(IMAGE)
    res = pink.seuil(dlma, la, 0, 255)
    return pink.float2byte(res)
Example #10
0
def seg_black(image, thr1):
    t1 = pink.seuil(image, thr1)
    return (inv(t1))
Example #11
0
def seg_gray(image, thr1, thr2):
    t1 = pink.seuil(image, thr1)
    t2 = pink.seuil(image, thr2)
    res = pink.asf(t1 - t2, 2)
    return (res)
Example #12
0
def rm(q):
    return pink.seuil(res, q)
Example #13
0
def seg_white(image, thr, size_open, size_close):
    r1 = pink.seuil(image, thr)
    r2 = pink.areaopening(r1, 26, size_open)
    res = pink.areaclosing(r1, 6, size_close)
    return (res)
Example #14
0
def ss(q):
    return pink.seuil(image, q)
Example #15
0
# UjoImro, 2010
# CeCILL free-software license

# Hugues' TP-2 / Segmentation1

from pink import cpp as pink

# ex 4.1
numbers = pink.readimage("../images/numbers.pgm")
ball = pink.genball(5)
openn = pink.opening(numbers, ball)
normalized = pink.seuil(numbers - openn, 10, 0, 255)
normalized.writeimage("normalized.pgm")

# ex 5.1-1
cell = pink.readimage("../images/cell.pgm")
ball = pink.genball(1)
dcell = pink.dilation(cell, ball)
ecell = pink.erosion(cell, ball)
pink.normalize(dcell - ecell).writeimage("grad.pgm")

# ex 5.1-2
## HELP ME!!!

#ex 6.1-1
bloodcells = pink.readimage("../images/bloodcells.pgm")
marker = pink.char_image(bloodcells.size)
marker[[50, 50]] = 255
marker.writeimage("marker.pgm")
ws = pink.watershed(bloodcells, marker, 8)
Example #16
0
def try_seuil(s):
    return pink.seuil(circuit, s, 0, 255)
Example #17
0
def s2(q):
    return pink.seuil(res, q)
Example #18
0
def sm(q):
    return pink.seuil(img, q)
Example #19
0
def try_DLMA_topo(la):
    dlma = pink.lambdamedialaxis(IMAGE)
    constr = pink.seuil(dlma, la, 0, 255)
    constr = pink.float2byte(constr)
    res = pink.skeleton(IMAGE, dlma, 8, constr)
    return res
Example #20
0
# wd.options.silent=False

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")
Example #21
0
def sm(q): return pink.seuil(img,q)
def rm(q): return pink.seuil(res,q)
Example #22
0
def rm(q): return pink.seuil(res,q)

if debug:
Example #23
0
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")
inv = pink.inverse(circuit)
inv = pink.seuil(inv, 180, 0, 255)
inv = filter_noise(inv)
viewer2 = Imview(inv)
#inv.writeimage("circ.pgm")

# Filtering out the strips to get the round ends
round = pink.openball(inv, 5, 0)
# plus one round of geodesic dilation to get the shape back
roundok = pink.geodilat(round, inv, 8, 1)  # note the 1 here
viewer2.show(roundok, "roundok")

# get the strips by difference
strips = inv - roundok
viewer2.show(strips, "strips")

## dilation
Example #24
0
def s2(q): return pink.seuil(res, q)

manipulate(s2, 0, 255)